1
我在Ruby中制作一个简单的应用程序我需要获取用户的电子邮件。我正在使用适用于Ruby的Google API客户端。我无法获取用户的电子邮件地址,我一直在研究这个主题2天,并且无法在用户登录后获得用户的电子邮件。我不想用Google+登录按钮来完成此操作我希望以编程方式进行操作。我得到谷歌授权,但不知道如何检索登录用户的用户信息。我试过也尝试过client = Google::APIClient.new
,但我没能力。以下是我的代码。我会感谢你的帮助。无法从Ruby中的google api获取用户信息
scopes = ['https://www.googleapis.com/auth/calendar', 'https://www.googleapis.com/auth/calendar.readonly', 'https://www.googleapis.com/auth/plus.login','https://www.googleapis.com/auth/userinfo.email']
client_secrets = Google::APIClient::ClientSecrets.load(SECRETS_PATH)
auth_client = client_secrets.to_authorization
auth_client.update!(
:additional_parameters => {"access_type" => "offline"}
)
auth_client.update!(
:scope => scopes,
:redirect_uri => 'http://localhost:3000/google_oauth2')
嘿,感谢完整的用户信息很多,让我来试试吧。 –
如果您在此处只需要帮助,请点击此处 –
Google+现已老化,不应使用。有没有其他方法? – archana