Created
April 24, 2016 11:01
-
-
Save mizalewski/1b48b86771fc1ffb020f95387613331f to your computer and use it in GitHub Desktop.
Get user info using OAuth2 (https://github.com/intridea/oauth2)
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
client = OAuth2::Client.new Figaro.env.omniauth_google_oauth2_app_id, | |
Figaro.env.omniauth_google_oauth2_app_secret, | |
{ site: 'https://accounts.google.com', authorize_url: '/o/oauth2/auth', token_url: '/o/oauth2/token' } | |
token = client.auth_code.get_token '4/authcode', {} | |
json = JSON.parse token.get('https://www.googleapis.com/plus/v1/people/me/openIdConnect').body | |
id = json['sub'] | |
first_name = json['given_name'] | |
last_name = json['family_name'] | |
email = json['email'] | |
email_verified = json['email_verified'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment