Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/darrenpeters/shoauth
Shopify oauth (oauth2) middleware for Golang
https://github.com/darrenpeters/shoauth
Last synced: 15 days ago
JSON representation
Shopify oauth (oauth2) middleware for Golang
- Host: GitHub
- URL: https://github.com/darrenpeters/shoauth
- Owner: darrenpeters
- License: mit
- Created: 2015-03-22T17:28:55.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-04-18T15:51:22.000Z (over 9 years ago)
- Last Synced: 2024-11-03T14:35:47.367Z (about 1 month ago)
- Language: Go
- Homepage: http://godoc.org/github.com/darrenpeters/shoauth
- Size: 148 KB
- Stars: 10
- Watchers: 1
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-shopify - shoauth - Shopify oauth (oauth2) middleware for Golang. (Libraries / Golang)
README
# shoauth
`shoauth` is an HTTP package for Go that implements the Shopify oauth2 API.
### Features
* Performs Shopify app installation (displaying auth page and retrieving access tokens)
* Optionally performs webhook installation upon app installation
* Performs Shopify request verification (both user & webhook)
* Acts as typical Go middleware - meaning it can be placed in any middleware stack as long as it is made up of `http.Handler`
* Allows custom failure handlers.
* Has no dependencies external to the Go standard library.### Example
```go
package mainimport (
"fmt"
"github.com/darrenpeters/shoauth"
"net/http"
"os"
)type dummyPersistence struct {}
func (p *dummyPersistence) InstallationExists(shopID string) bool {
return false // Use any ORM or SQL package directly
}func (p *dummyPersistence) CreateInstallation(shopID string, accessToken string) error {
return nil // Use any ORM or SQL package directly
}func (p *dummyPersistence) HasValidSession(r *http.Request) bool {
return false // Use gorilla sessions or whatever here
}func oauthConfig(s *shoauth.ShopifyConfig) {
s.ClientID = os.Getenv("SHOPIFY_CLIENT_ID")
s.SharedSecret = os.Getenv("SHOPIFY_SHARED_SECRET")
s.IsEmbedded = true
s.Scopes = []string{"read_products", "write_products", "read_customers", "write_customers", "read_orders", "write_orders", "read_shipping", "write_shipping"}
s.Webhooks = make(map[string]string)
s.Webhooks["orders/fulfilled"] = "https://yourapp.com/orders/fulfilled"
s.Webhooks["app/uninstalled"] = "https://yourapp.com/app/uninstalled"
}func main() {
shoauthHandler := shoauth.NewShopifyOauthHandler(http.DefaultServeMux, shoauth.DefaultFailureHandler(), &dummyPersistence{}, oauthConfig)
fmt.Println("Listening on http://127.0.0.1:8000/")
http.ListenAndServe(":8000", shoauthHandler)
}
```### Documentation
Documentation is available at [GoDoc](http://godoc.org/github.com/darrenpeters/shoauth)