Authentication
Exchange your consumer key and secret for a short-lived bearer token.
Get your credentials
Open Credentials in the dashboard and create a consumer key and secret for the environment you need. Give each integration its own named credential. The secret is shown once, so store it somewhere safe. If you lose it, rotate the secret.
Rotate or revoke
Rotating issues a new secret for the same consumer key. Choose how long the old secret keeps working (immediately, 1 hour, 24 hours or 7 days) so you can deploy the new one without downtime. Rotating immediately also ends every token issued before the rotation. Revoking a credential is permanent: it can no longer request tokens, and tokens it already holds are refused.
Request a token
Call GET /oauth/v1/generate with HTTP Basic authentication, using your consumer key as the username and your consumer secret as the password.
curl -s "https://api.kipay.co.ke/oauth/v1/generate?grant_type=client_credentials" \
-u "$CONSUMER_KEY:$CONSUMER_SECRET"Response
{
"access_token": "eyJhbGciOi...",
"expires_in": "3599"
}Use the token
Send the token as a Bearer token on every STK Push and STK Query call. Tokens last about an hour; request a new one when it expires.
Authorization: Bearer <access_token>