An example app to demonstrate torii.
Create a google application.
client_id
(can ignore the client_secret
for now)config/environment.js
set the apiKey
property to your copied client_id
for the 'google-oauth2-bearer' providerOptionally change scopes by setting the 'scopes' parameter to 'profile' or 'email' in your configuration. List of Google OAuth login scopes. The default scope for the google-oauth2-bearer is email if none is explicitly configured.
First, follow the steps as above for the implicit grant flow.
If it is not already present add a configuration section in config/environment.js
for
a torii provider called 'google-oauth2'. Use the same apiKey
and redirectUri
values
as for the google-oauth2-bearer
provider.
Authorization Code Grant flow requires a server-side component.
There is a simple server running at heroku that can exchange an authorization code. The configuration already points at this endpoint to handle the server-side exchange for the access token. Demo server code is at: https://github.com/bantic/torii-example-for-global-ember-backend
Follow the steps above for the authorization code grant flow.
Ensure the torii configuration specifies a sessionServiceName
property of 'session'. This is necessary to opt-in to Torii's session management.
Notice that a torii-adapter called 'application' has been created.
When signing in with google, the torii session service will:
open
the torii built-in 'google-oauth2' provider, resulting in an authorization codeopen
method of the 'application' adapter{currentUser}
objectcurrentUser
property and transitions the session to its authenticate state