Created
April 17, 2016 10:36
-
-
Save nov/3f284aa8cec5ed6bc332e9a5c9d93851 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'openid_connect' | |
OpenIDConnect.debug! | |
config = OpenIDConnect::Discovery::Provider::Config.discover! 'https://sts.example.com/adfs' | |
client = OpenIDConnect::Client.new( | |
identifier: '2940bc16-983c-41ca-b373-4c6045278627', # Native App's client_id | |
redirect_uri: 'custom-schema://foobar', | |
authorization_endpoint: config.authorization_endpoint, | |
token_endpoint: config.token_endpoint, | |
userinfo_endpoint: config.userinfo_endpoint | |
) | |
authorization_uri = client.authorization_uri( | |
scope: [:openid, :email, :profile] | |
) | |
puts authorization_uri | |
`open "#{authorization_uri}"` | |
code = gets.chop! | |
client.authorization_code = code | |
token = client.access_token! # aud = urn:microsoft:userinfo | |
token.userinfo! | |
client.refresh_token = token.refresh_token | |
token2 = client.access_token!( | |
resource: 'http://backend.dev' # Native App Backend's identifier | |
) # aud = http://backend.dev |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment