Access Tokens
To interact with the NationBuilder API v2, you need a refreshing API token. This token is essential for authenticating your requests and accessing the API’s resources.
Generating a Test Token:
Navigate to the NationBuilder control panel.
Go to Settings > Developer > API token.
Generate a test token. Note that this token will expire in 24 hours.
For production use, you will need to generate tokens via the OAuth flow. For more information, refer to the migration guide.
Example:
curl -H "Authorization: Bearer YOUR_ACCESS_TOKEN" https://api.nationbuilder.com/v2/your_endpoint
Refreshing Tokens
OAuth tokens typically have an expiration time, after which they need to be refreshed. To refresh your token, you will use the refresh token obtained during the initial authentication process.
Send a POST request to the token endpoint with the refresh token.
Retrieve the new access token from the response.
Example:
POST /oauth/token Host: www.nationbuilder.com Content-Type: application/json { "grant_type": "refresh_token", "refresh_token": "YOUR_REFRESH_TOKEN", "client_id": "YOUR_CLIENT_ID", "client_secret": "YOUR_CLIENT_SECRET" }