Create a key pair
This guide uses an Ed25519 key, which signs with theEdDSA algorithm. The token_endpoint_auth_signing_alg_values_supported field of the server metadata lists all the algorithms that the server accepts.
Use OpenSSL 3.0 or later, and run the commands on your own machine. Never use a web tool to create a private key.
On macOS, the
openssl command is LibreSSL. Older LibreSSL versions cannot create Ed25519 keys and show the error Algorithm ED25519 not found. Install OpenSSL 3 with Homebrew and put it first in your PATH:1
Create the private key
The command writes a PEM file in the PKCS#8 format:
2
Derive the public key
3
Verify the key pair
Make sure that the public key comes from the private key. The two fingerprints must be equal:
Register your public key
Sendpublic.pem to Gnosis Pay. Never send the private key. If you send a private key by mistake, create a new key pair.
Gnosis Pay registers the key and supplies these values for each environment. Store them as configuration, not in code.
The
kid is the RFC 7638 JWK thumbprint of the public key, with SHA-256 and base64url without padding. Your backend can also compute it from the key. The Go sample shows how.
Get and use a token
1
Read the server metadata
The server metadata (RFC 8414) gives the The token endpoint is
issuer, the token_endpoint, and the accepted signing algorithms:cURL
POST <issuer>/oauth/token.2
Sign a client assertion
Create a compact JWS with one signature and these headers and claims:
The server accepts a clock skew of 30 seconds. Sign a new assertion for each token request. Do not reuse an assertion.
3
Request an access token
Send the client assertion to the token endpoint as an A success response has status The access token is valid for 15 minutes.
application/x-www-form-urlencoded body:cURL
200:4
Cache the token
Use the same access token for all API calls until its refresh time. Then request a new token. Don’t request a new token for every API call.
5
Send the token with every request
Pass the token as a bearer token in the
Authorization header:cURL
A token is scoped to one partner organization, so you don’t send an organization ID in Partner API requests. The token gives access to every resource in your organization. Check that a resource belongs to the requesting user before you act on it.
Token request reference
Parameters
Send each parameter one time only. The server reads the parameters only from the body, not from the query string.Errors
An error response follows RFC 6749 §5.2:Rate limits
Go sample
The sample usesgithub.com/lestrrat-go/jwx/v4 and needs Go 1.27 or later. It does these steps:
- Load the private key from
private.pemand compute itskid. - Sign the client assertion.
- Exchange the client assertion for an access token.
- Print the access token on stdout.
issuer and clientID constants with the values from your integration.
main.go
main.go
main.go
Next step
Configure webhooks
Set up an endpoint to receive state changes from Gnosis Pay.