Documentation Index
Fetch the complete documentation index at: https://docs.grainledger.com/llms.txt
Use this file to discover all available pages before exploring further.
Overview
The Grain API uses OAuth 2.1 (Sign in with Grain) for authentication. Users authorize your application to access their church data, and you receive an access token to make API calls on their behalf.OAuth 2.1 Flow
- Redirect to authorize – Redirect the user to the Grain authorization endpoint with your client ID, redirect URI, scopes, and PKCE parameters.
- User consents – The user signs in (if needed) and approves access at
https://app.grainledger.com/oauth/consent. - Receive authorization code – The user is redirected back to your
redirect_uriwith an authorization code. - Exchange for tokens – Exchange the code for access and refresh tokens at the Grain token endpoint.
- Call the API – Include the access token in the
Authorization: Bearer <token>header andX-Organization-Idin every request.
OAuth Endpoints
| Purpose | URL |
|---|---|
| Authorization | https://app.grainledger.com/oauth/authorize |
| Token | https://api.grainledger.com/oauth/token |
| Consent UI | https://app.grainledger.com/oauth/consent |
| Discovery | https://api.grainledger.com/.well-known/oauth-authorization-server |
X-Organization-Id Header
Every API request must include the organization (church) whose data you are accessing:Scopes
Standard OIDC scopes control user profile data in tokens:| Scope | Description |
|---|---|
openid | OpenID Connect identity |
email | Email address |
profile | Name and profile information |
phone | Phone number |
Example Request
Token Refresh
Use the refresh token from the token exchange to obtain new access tokens when they expire. Call the token endpoint withgrant_type=refresh_token and your refresh token.
