View Source SimpleOAuth
The following platform logins are supported:
Configurations
Setup runtime configuration.
config :simple_oauth, [keyword configurations]config :simple_oauth,
[
google: [
client_id: {client_id},
client_secret: {client_secret},
host: {host},
scope: {scope}, # optional, default: "profile email"
callback_path: {callback_path}, default: "/oauth/google/callback"
]
]Usage
There are 3 main context apis (under SimpleOAuth.Google):
oauth_url/0/oauth_url/1- login google account and google will call the callback api;token/0/token/1- get token (includeaccess_token) by the callback request;user_info/1- get user info (include email/name/avatar and ect.) byaccess_token.
To get user info by the callback api request (code is the parameter):
{:ok, token} = SimpleOAuth.Google.token(code)
{:ok, profile} = SimpleOAuth.Google.user_info(token["access_token"])