-
-
Notifications
You must be signed in to change notification settings - Fork 119
Client Init
nov edited this page Oct 8, 2022
·
4 revisions
client = Rack::OAuth2::Client.new(
identifier: YOUR_CLIENT_ID,
secret: YOUR_CLIENT_SECRET,
redirect_uri: YOUR_REDIRECT_URI,
host: 'server.example.com'
)
rack-oauth2 uses /oauth2/authorize
and /oauth2/token
as default paths.
In the above case, client
uses
-
https://server.example.com/oauth2/authorize
as Authorization Endpoint -
https://server.example.com/oauth2/token
as Token Endpoint
If your client is Public Client, then omit secret
.
You can optionally specify authorization_endpoint
and/or token_endpoint
as absolute/relative URLs.
If the host component of authorization_endpoint
and token_endpoint
are different, you'll specify absolute URLs.
In that case, you can omit host
param.
client = Rack::OAuth2::Client.new(
identifier: YOUR_CLIENT_ID,
secret: YOUR_CLIENT_SECRET,
redirect_uri: YOUR_REDIRECT_URI,
authorization_endpoint: 'https://www.facebook.com/oauth/dialog',
token_endpoint: 'https://graph.facebook.com/oauth/token'
)
If the host of 2 endpoints are same, but the path doesn't match rack-oauth2 default, you'll specify host
and relative URLs.
client = Rack::OAuth2::Client.new(
identifier: YOUR_CLIENT_ID,
secret: YOUR_CLIENT_SECRET,
redirect_uri: YOUR_REDIRECT_URI,
host: 'github.com',
authorization_endpoint: '/#/oauth/authorize',
token_endpoint: '/#/oauth/access_token'
)