Client Init - nov/rack-oauth2 GitHub Wiki
Minimum Setting
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/authorizeas Authorization Endpointhttps://server.example.com/oauth2/tokenas Token Endpoint
If your client is Public Client, then omit secret.
Customization
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: '/login/oauth/authorize',
token_endpoint: '/login/oauth/access_token'
)