scientific-skills/protocolsio-integration/references/authentication.md
The protocols.io API supports two types of access tokens for authentication, enabling access to both public and private content.
All API requests must include an Authorization header:
Authorization: Bearer [ACCESS_TOKEN]
Direct users to the authorization URL to grant access:
GET https://protocols.io/api/v3/oauth/authorize
Parameters:
client_id (required): Your application's client IDredirect_uri (required): URL to redirect users after authorizationresponse_type (required): Set to "code"state (optional but recommended): Random string to prevent CSRF attacksExample:
https://protocols.io/api/v3/oauth/authorize?client_id=YOUR_CLIENT_ID&redirect_uri=YOUR_REDIRECT_URI&response_type=code&state=RANDOM_STRING
After user authorization, protocols.io redirects to your redirect_uri with an authorization code. Exchange this code for an access token:
POST https://protocols.io/api/v3/oauth/token
Parameters:
grant_type: Set to "authorization_code"code: The authorization code receivedclient_id: Your application's client IDclient_secret: Your application's client secretredirect_uri: Must match the redirect_uri used in Step 1Response includes:
access_token: The OAuth access token to use for API requeststoken_type: "Bearer"expires_in: Token lifetime in seconds (typically 1 year)refresh_token: Token for refreshing the access tokenBefore the access token expires (typically 1 year), use the refresh token to obtain a new access token:
POST https://protocols.io/api/v3/oauth/token
Parameters:
grant_type: Set to "refresh_token"refresh_token: The refresh token received in Step 2client_id: Your application's client IDclient_secret: Your application's client secretBe aware of rate limiting when making API requests:
/view/[protocol-uri].pdf):