Login OAuth2.0:我可以';t从谷歌获取个人资料信息“;令牌信息端点“;通过使用id_令牌
我正在尝试使用OAuth2.0从谷歌获取用户信息(个人资料、电子邮件) 但“令牌信息端点”并没有返回配置文件信息,即使我将“配置文件”设置为作用域 我跟踪了谷歌登录iOS的文档。() 我不明白为什么这个端点没有像我期望的那样返回配置文件信息 首先,我通过oauth2.0获得令牌(作为测试,我使用Rails获得令牌) def gmail 需要“oauth2” client=OAuth2::client.new( “客户端id”, “客户机密”, { 地点:'https://accounts.google.com/', 授权url:'o/oauth2/auth', } ) 重定向到client.auth\u code.authorize\u url( 重定向_uri:'http://localhost:3000/google_signup', 范围:“电子邮件配置文件”, ) 结束Login OAuth2.0:我可以';t从谷歌获取个人资料信息“;令牌信息端点“;通过使用id_令牌,login,oauth-2.0,google-login,Login,Oauth 2.0,Google Login,我正在尝试使用OAuth2.0从谷歌获取用户信息(个人资料、电子邮件) 但“令牌信息端点”并没有返回配置文件信息,即使我将“配置文件”设置为作用域 我跟踪了谷歌登录iOS的文档。() 我不明白为什么这个端点没有像我期望的那样返回配置文件信息 首先,我通过oauth2.0获得令牌(作为测试,我使用Rails获得令牌) def gmail 需要“oauth2” client=OAuth2::client.new( “客户端id”, “客户机密”, { 地点:'https://accounts.goo
令牌=client.auth\u code.get\u令牌(
参数[:代码],
重定向_uri:'http://localhost:3000/gmail_signup',
我从这个令牌中获得id\u令牌
然后,将GET请求发送到“令牌信息端点”
”https://www.googleapis.com/oauth2/v3/tokeninfo?id_token=id_token“
但回复中没有包含个人资料信息
{
"azp": "azp",
"aud": "aud",
"sub": "sub",
"email": "email@gmail.com",
"email_verified": "true",
"at_hash": "at_hash",
"exp": "TIMESTAMP",
"iss": "accounts.google.com",
"iat": "iat",
"alg": "alg",
"kid": "kid"
}
反应应该是这样的
{
// These six fields are included in all Google ID Tokens.
"iss": "https://accounts.google.com",
"sub": "110169484474386276334",
"azp": "1008719970978-hb24n2dstb40o45d4feuo2ukqmcc6381.apps.googleusercontent.com",
"aud": "1008719970978-hb24n2dstb40o45d4feuo2ukqmcc6381.apps.googleusercontent.com",
"iat": "1433978353",
"exp": "1433981953",
// These seven fields are only included when the user has granted the "profile" and
// "email" OAuth scopes to the application.
"email": "testuser@gmail.com",
"email_verified": "true",
"name" : "Test User",
"picture": "https://lh4.googleusercontent.com/-kYgzyAWpZzJ/ABCDEFGHI/AAAJKLMNOP/tIXL9Ir44LE/s99-c/photo.jpg",
"given_name": "Test",
"family_name": "User",
"locale": "en"
}