使用XML中的oAuth获取Google用户名 [英] Get Google Username with oAuth in XML

查看:130
本文介绍了使用XML中的oAuth获取Google用户名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在无法获取登录的Google用户名.我想从此链接获取所需的数据:

I'm having trouble right now getting the username of the logged in Google User. I want to get the Data I need from this Link:

https://accounts.google.com/o/oauth2/auth?
scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.profile&
state=%2Fprofile&
redirect_uri={REDIRECT_URL}
response_type=token&
client_id={CLIENT_ID}

此链接通过oAuth进行身份验证并获取我的帐户信息,但是我不想使用"Redirect_URL",我只想将数据作为XML文件获取并与JavaScript一起使用.我希望此链接在我的Google协作平台小工具中运行,因此我可以在小工具中使用此链接中的数据.

this link authenticates with oAuth and gets my Account information, but i don't want to use a "Redirect_URL" i just want to get the data as an XML-File and use it with JavaScript. I want this link to run in my Gadget for Google Sites, so i can use the data from this link in my Gadget.

推荐答案

从您的问题中,我认为您误解了Oauth2流程.

From your question I think you misunderstand the Oauth2 flow.

您将用户重定向到Google的URL,在该URL中,用户将使用自己的Google凭据进行身份验证.因此,用户在Google网站上进行身份验证,而不是在您的应用程序内部进行身份验证.这可以确保用户不必在Google之外的任何其他应用程序/站点中填写其凭据.当用户接受您的应用对他们信息的使用后,Google会调用您的重定向网址,并为您提供代码,您可以使用该代码获取用户数据.因此,由您来决定是否要从Google重定向并在回调(您的重定向URL)中使用从Google获得的代码来请求所需的数据.

You redirect the user to Googles url where the user authenticates himself with his google credentials. So the user authenticates on the google website and not inside your application. This to make sure that a user doesn't have to fill in his credentials in any other application/site then google. When the user has accepted the use of their information by your app google will call your redirect url and provide you with a code which you can use to get the user data. So it is up to you to catch the redirect from Google and request the data you need with the code you get from Google inside the callback (your redirect url).

也请看一下这张图片:

这篇关于使用XML中的oAuth获取Google用户名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆