Account OAuth Flow
Aurinko's Account OAuth Flow is a user-delegated authorization flow, producing an Aurinko account and an access token for secure API access.
Last updated
Aurinko's Account OAuth Flow is a user-delegated authorization flow, producing an Aurinko account and an access token for secure API access.
Last updated
This is a standard flow for getting access to a remote account. To enable Google and Office 365 OAuth flow for production, please see the following instructions Office365 OAuth Setup and Google OAuth Setup.
This flow uses user-delegated authorization and produces an Aurinko account and an access token.
Some key terms you'll encounter while integrating with Aurinko's OAuth2 flow:
The final callback URL, also known as returnUrl
, is the URL provided by your application and specified when calling the /authorize
API method within Aurinko. This is where Aurinko will redirect the user after successful authorization. It's crucial to register this URL within the Aurinko settings for your application.
Think of it as: Your application's "homecoming" address after the user completes the authorization process with an OAuth2 provider (like Google or Microsoft).
The intermediate redirect URL is a temporary landing page used during the OAuth2 flow. By default, Aurinko uses https://api.aurinko.io/v1/auth/callback
for this purpose. However, developers have the flexibility to customize this URL within the Aurinko settings for their application.
Imagine it as: A "waiting room" where Aurinko receives the user's authorization decision from the OAuth2 provider before sending them back to your application's final callback URL.
The following diagram shows a standard flow with the default intermediate URL.
From your application, redirect users to https://api.aurinko.io/v1/auth/authorize
, with the query parameters detailed in /auth/authorize. You'll need to set the responseType=code
.
Note: responseType=token
for client-side flows (corresponding to the OAuth's implicit grant) is supported but is not recommended!
You'll also need to determine what permissions your application will request from users, and update the scopes
query parameter accordingly. Aurinko provides granular authentication scopes that empower users with control over what level of access your application has to their data. See supported Authentication scopes for details.
Here's an example of what this URL might look like once you've included all the correct query parameters:
Redirect URI: Intermadiate Redirect page vs. Custom domain alias
Google app registrations allow only authorized redirect URIs under a domain you own so the default Aurinko's Redirect URI (Intermediate Redirect URL) https://api.aurinko.io/v1/auth/callback
won't work for you in production.
You have two options:
Contact us about provisioning a domain alias for your Aurinko app so you can use a url like https://aurinko.mydomain/v1/auth/callback
Create your intermediate redirect page to use for redirecting all calls to Aurinko's https://api.aurinko.io/v1/auth/callback
with the URL parameters state
, code
, and scope
.
The following diagram shows a custom OAuth flow with your intermediate redirect URL.
User Consent
Aurinko will present your user with the correct sign-in form based on the requested service type (Google, Office365, EWS). For Exchange users, the user has to enter a login name and an Exchange server URL.
Getting the token
Once the user has signed in and authorized your app's access, their browser will be redirected to the returnUrl
you provided.
Implicit Grant (responseType=token
)
If the authentication is successful Aurinko will include the hash fragment #accessToken={accessToken}
with the account access token. That's it!
Example redirect URL: https://your-app.com/callback?#accessToken={token}&state={state}&status=success
We recommend storing the accessToken
and then removing it from the hash fragment with JavaScript. This is the token you will provide as an HTTP Bearer Auth
to make API calls on behalf of the user.
Authorization Code Grant (responseType=code
)
If the authentication is successful Aurinko will include the code
parameter in the query string.
Example redirect URL: https://your-app.com/callback?code={code}&state={state}&status=success
Make an HTTP POST call to https://api.aurinko.io/v1/auth/token/{code}
to exchange the code
for an access_token
.
Response:
See /auth/token for details. Make sure to securely store the accessToken
and provide it as the HTTP Bearer Auth
token to make API calls on behalf of the user (see Authentication details).