Get Google Username with oAuth in XML

2019-08-17 04:33发布

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}

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.

1条回答
Deceive 欺骗
2楼-- · 2019-08-17 04:48

From your question I think you misunderstand the Oauth2 flow.

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).

Also take a look at this image:

enter image description here

查看更多
登录 后发表回答