DailyPay adheres to the OAuth 2.0 RFC 6749 and OpenID Connect specifications. This document will walk you through the steps to get an access token your application can use to make requests to the DailyPay Public REST API.
We support the following methods:
Authorization Code Flow: This method is suitable when access to resources requires user consent, such as bank account information or the ability to initiate transfers on behalf of the user.
It allows your application to get
access
andrefresh
tokens, facilitating user consent and enabling your application to perform actions on their behalf.
Client Credential Flow: This method is suitable for server-to-server operations, where additional levels of user consent may not be required.
The client credentials grant facilitates the acquisition of an access token independent of a user's protected resources. For instance, you can utilize the Organizations endpoint.
The purpose of following the OAuth2 flow is to help you retrieve an authorization code
and exchange it for an access_token
via the request access token endpoint.
Your DailyPay contact will ask you to provide
code
result of the OAuth 2.0 authorization code flowDailyPay will provide configuration values for your application:
client_id
client_secret
, if applicablescope
a list of scopes your application can request, which may include "offline_access" and "openid"redirect_uri
the registered callback url you providedYou may wish to use a client library (https://oauth.net/code/) to perform the next steps, using the configuration values above.
Construct the request url using the template below, replacing the {scope}
, {client_id}
, and {redirect_uri}
parameters with the configuration values accordingly.
Additionally, generate a state
parameter for the specific request, and a code challenge and verifier (used in a later step) for Proof Key Code Exchange.
https://auth.dailypay.com/oauth2/auth
?response_type=code
&scope={scope}
&client_id={client_id}
&redirect_uri={redirect_uri}
&state={state}
&code_challenge={code_challenge}
&code_challenge_method=S256
https://auth.dailypay.com/oauth2/auth
?response_type=code
&scope=user%3aread_write%20openid
&client_id=your-client-id
&redirect_uri=https%3A%2F%2Fexample.com%2Fcallback
&state=9876543fghijklm
&code_challenge=hKpKupTM391pE10xfQiorMxXarRKAHRhTfH_xkGf7U4
&code_challenge_method=S256
Make sure to url-encode each parameter e.g. user:read_write
becomes user%3aread_write
The user will be prompted to log in or create a new DailyPay account and will be prompted to allow your application to act on their behalf.
Users will be redirected in the open tab to your callback url with a code
query parameter,
or an error
and error_description
if the user did not consent to your application's request or otherwise encountered an error.
You will also be returned the state
parameter.
As also specified in our token endpoint documentation, send the following parameters www-form-encoded in the request body to https://auth.dailypay.com/oauth2/token.
Parameter | Required | Description |
---|---|---|
grant_type | Yes | Must be set to authorization_code . |
client_id | Yes | Your client id provided by DailyPay. |
code | Yes | The authorization code received from the authorization server. |
redirect_uri | Yes | MUST be the redirection URI used in the initial authorization request. |
client_secret | Varies | Your client secret, if provided by DailyPay. |
code_verifier | Varies | The PKCE verifier matching the code_challenge generated earlier. |
Example Request to the Token Endpoint
curl --request POST \
--url https://auth.dailypay.com/oauth2/token \
--header 'accept: application/json' \
--header 'content-type: application/x-www-form-urlencoded' \
--data "grant_type=authorization_code" \
--data "client_id={client_id}" \
--data "code={code}" \
--data "redirect_uri={redirect_uri}" \
--data "code_verifier={verifier}"
The resulting access token can be used to make requests to the DailyPay Public REST API:
{
"access_token": "dpo_38347Ae178B4a16C7e42F292c6912E7710c8",
"token_type": "bearer",
"expires_in": 3600,
"created_at": 1669741580
}
The authorization code, access token, and refresh tokens can vary in size but will typically remain under 4096 btyes.
As also specified in our token endpoint documentation, send the following parameters www-form-encoded in the request body to https://auth.dailypay.com/oauth2/token.
Parameter | Required | Description |
---|---|---|
grant_type | Yes | Must be set to client_credentials . |
scope | Yes | The space-delimited list of requested scopes |
client_id | Yes | Your client id provided by DailyPay. |
client_secret | Yes | Your client secret provided by DailyPay. |
Example Request to the Token Endpoint
curl --request POST \
--url https://auth.dailypay.com/oauth2/token \
--header 'accept: application/json' \
--header 'content-type: application/x-www-form-urlencoded' \
--data "grant_type=client_credentials" \
--data "scope={scopes}" \
--data "client_id={client_id}" \
--data "client_secret={client_secret}"
The resulting access token can be used to make requests to the DailyPay Public REST API:
{
"access_token": "dpo_38347Ae178B4a16C7e42F292c6912E7710c8",
"token_type": "bearer",
"expires_in": 3600,
"created_at": 1669741580
}
The authorization code, access token, and refresh tokens can vary in size but will typically remain under 4096 btyes.
Request a Dailypay user access token, as described in the OAuth2 spec. When grant_type is authorization_code, the code and redirect_uri parameters are required. When grant_type is refresh_token, the refresh_token parameter is required.
DailyPay user access token
Something went wrong when exchanging oauth grant or refresh token for an access token. NOTE: This conforms to the OAuth spec and does not follow the same error pattern as the rest of the API
Unexpected error occured
grant_type=authorization_code&code=50BTIf2h7Wtg3DAk7ytpG5ML_PsNjfQA4M7iupH_3jw&redirect_uri=https%3A%2F%2Fexample.com%2Fcallback&code_verifier=string&client_id=string&client_secret=string
{- "access_token": "dpo_38347Ae178B4a16C7e42F292c6912E7710c8",
- "refresh_token": "dpo_38347Ae178B4a16C7e42F292c6912E7710c9",
- "token_type": "bearer",
- "scope": "user:read_write",
- "id_token": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.4FjJ3eZJYJj7J9Jf",
- "expires_in": 3600
}