A Go module to generate authentication details to communicate with Modo servers
Credentials that are created and shared by Modo. These will be different for each environment (int
, prod
, local
etc...).
api_identifier
- API key from Modoapi_secret
- API secret from Modo
These values will be used when intantiating the library.
Presently, the github repo is private, so you'll need to tell go
that:
# add env var via `~/.zshrc` or `~/.bashrc` or the like
export GOPRIVATE="github.com/modopayments-ux,github.com/modopayments"
Restart your terminal
# in the root of the project
go get github.com/modopayments-ux/modo2auth-go
Here's an example using ...
to make requests. You can use your preferred method or library.
package main
import (
"net/http"
"github.com/modopayments-ux/modo2auth_go"
)
const endpoint = "http[URL_HERE]"
func main() {
id := modo2auth_go.ID{
Key: "7g0UApipMpuJ1VOOOHWJNIZH7VZINb08",
Secret: "20I1s7GH7-pgn9041cgWlBKU8pcA1I4CCNpGuvu_xL4K-GnRSy3Q6IBtA5LYlIjy",
}
req, _ := http.NewRequest(http.MethodPost, endpoint+"/v3/checkout/list", nil)
_ = id.Sign(req)
}
ID
(struct) with the following properties:
Key
(string) - API key from ModoSecret
(string) - API secret from Modo
Adds an "Authorization" header to the provided request, signed using the credentials in ID. The request must not be modified after being signed
Returns a signature for use in an Authorization header. iat should normally be the current time. api must be the API path (ex. "/v3/checkout/list"), NOT the full URL.
Prerequisite: go
installed globally
- Install
go install .
- Unit test -
go test ./...
- Fork this repo via Github
- Create your feature branch (
git checkout -b feature/my-new-feature
) - Ensure unit tests are passing (
go test ./...
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin feature/my-new-feature
) - Create new Pull Request via Github
Prequisite: Need to have go
installed on your system. At the root of this directory, do the following:
- Commit and push (
git commit -am 'Version bump'
) - Tag with new version
git tag v1.1.0
(example) - Push tags
git push --tags