Chrome Extensions with Google authentication
Integrate Google authentication into your Chrome extension using Aurinko's backend API for seamless user management and offline access.
Chrome extensions are plugin-like integrations built by third parties into Chrome. They are essentially JavaScript/HTML code that runs in the context of a browser page in a sandbox with special access to Chrome browser API.
Many Chrome extensions are built to provide convenient integrations to a third-party system or service, like Customer Relationship Management, Customer Service, and Project Management,... and the extension developers all end up developing the same or similar elements of their app:
Provision a backend API that will support the client code.
Implement user management (login/logout/session) which needs to be correlated with an authenticated user, often a Google or Office 365 user.
Support one or more 3rd party authorization flows. For example, a user needs to link his or her CRM account, maybe also a cloud file storage.
Proxy requests to 3rd party API's. Quite often direct API communications from JavaScript are blocked by CORS in browsers.
Storing various add-in configurations for users or organizations.
Offline API access. Often special workers are implemented to run in the background when an extension user is offline.
Aurinko aims to provide the necessary backend functionality for these extensions so that developers could focus on the client code to create the best user experiences. Here are the steps to start using Aurinko as a backend API for your Chrome extension:
Get your developer API keys and put your app's client id into your client code.
To provide Google authentication and to have offline Google API access provision Google OAuth setup.
After your extension client code has initialized test if the current user is already authenticated with Aurinko (logged in):
curl -X GET -G https://api.aurinko.io/v1/user
For a logged in user the request will return the user info and its active Aurinko accounts (see step 5). Otherwise, 401 Unauthorized status will be returned in which case your extension needs to ask the user to login (see next step).
To authorize a user start the authorization flow in a popup window. This way your extention can also get offline access to Google API:
The important parameter here is
userAccount=primary
which turns this account authorization into user session initialization (user login). Upon successful authentication and authorization, a session cookie is set which will allow your app to stay recognized by Aurinko until the user logs out.The following JavaScript code is executed in your popup
In addition to the login Aurinko gets access to Google API with the requested scopes: Mail.Send. This will allow your app to work with the Gmail account while the user is not using your extension.
Authorize access to a 3rd party API. Contact us at support@aurinko.io to arrange adding a connector for your system, i.e. {MyCRM}.
Upon a successful authentication and authorization an Aurinko account representing your 3rd party API {MyCRM} will be added and your app can issue the following request again :
curl -X GET -G https://api.aurinko.io/v1/user
The request will return all Aurinko accounts associated with the current user session:
Now your extension can access either Google API (through Aurinko's unified API) or the 3rd party API. Specify an account id in the special header
X-Aurinko-AccountId
and use Aurinko Email/Calendar/Contact to access those accounts.
Last updated