简体   繁体   English

获取ruby中的oauth2 access_token所有者电子邮件地址?

[英]Get oauth2 access_token owner email address in ruby?

I am successfully using Oauth2 gem to get an access tokens from Google accounts. 我已成功使用Oauth2 gem从Google帐户获取访问令牌 But I want to get the email address which produced the token (I mean if I used this account "myemail@gmail.com" to get the access_token, how can I know the email address from the token?). 但是我想获取产生令牌的电子邮件地址 (我的意思是,如果我使用此帐户“ myemail@gmail.com”来获取access_token,我如何从令牌中知道电子邮件地址?)。 Or can I get the email while obtaining the token? 还是可以在获取令牌时获取电子邮件?

Usually you can get that email with the response for any API call. 通常,您可以获取包含任何API调用响应的电子邮件。 For contacts API, by example, there is an entry called author in the response: https://developers.google.com/google-apps/contacts/v3/#retrieving_all_contacts 例如,对于联系人API,响应中有一个称为author的条目: https : //developers.google.com/google-apps/contacts/v3/#retrieving_all_contacts

Anyway, I'm not sure which gem you're using. 无论如何,我不确定您使用的是哪种宝石。 You can use oauth2 , doorkeeper or cloudsponge . 您可以使用的oauth2守门人cloudsponge

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM