-
-
Notifications
You must be signed in to change notification settings - Fork 123
Client Init
nov edited this page Jan 5, 2015
·
2 revisions
openid_connect gem is based on rack-oauth2 gem. Client initialization is basically following rack-oauth2 style.
client = OpenIDConnect::Client.new(
identifier: YOUR_CLIENT_ID,
secret: YOUR_CLIENT_SECRET,
redirect_uri: YOUR_REDIRECT_URI,
host: 'server.example.com'
)
rack-oauth2 gem uses /oauth2/authorize
and /oauth2/token
as default paths.
plus, openid_connect gem adds /userinfo
as default UserInfo endpoint path.
In the above case, client
uses
-
https://server.example.com/oauth2/authorize
as Authorization Endpoint -
https://server.example.com/oauth2/token
as Token Endpoint -
https://server.example.com/userinfo
as UserInfo 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 = OpenIDConnect::Client.new(
identifier: YOUR_CLIENT_ID,
secret: YOUR_CLIENT_SECRET,
redirect_uri: YOUR_REDIRECT_URI,
authorization_endpoint: 'https://server.example.com/authorize',
token_endpoint: 'https://auth.server.example.com/tokens',
userinfo_endpoint: 'https://api.server.example.com/userinfo'
)
If the host of 2 endpoints are same, but the path isn't mach rack-oauth2 default, you'll specify host
and relative URLs.
client = OpenIDConnect::Client.new(
identifier: YOUR_CLIENT_ID,
secret: YOUR_CLIENT_SECRET,
redirect_uri: YOUR_REDIRECT_URI,
host: 'connect-op.herokuapp.com',
authorization_endpoint: '/authorizations/new',
token_endpoint: '/access_tokens',
userinfo_endpoint: '/user_info'
)