Welcome Guest, Not a member yet? Register   Sign In
best way to do cross-site request?
#6

(This post was last modified: 03-07-2018, 01:05 PM by richb201.)

I am still at getting the token. When I run the code below I get a whole slew of fields about myself in response.

 response=
"{
"id": "1109308060260095483xx",
"email": "[email protected]",
"verified_email": true,
"name": "Richard Berns",
"given_name": "Richard",
"family_name": "Berns",
"link": "https://plus.google.com/1109308060260095483xx",
"picture": "https://lh4.googleusercontent.com/-tzUZ4ZmxxJM/AAAAAAAAAAI/AAAAAAAAAAA/HDERazJjQtE/photo.jpg",
"gender": "male"
}
"



        var x = new XMLHttpRequest();
          x.addEventListener("load",reqListener);   //this callabck means we got the email
          x.open('GET', 'https://www.googleapis.com/oauth2/v2/userinfo?alt=json&access_token=' + token);
          x.send();
  

function reqListener(){
console.log(this.response["email"]);
}     

But I only need the response.email field. I will use this as the key that I send to my CI daemon. How do I access the email field in response? My plan is to build a new XMLHttpRequest() to go over to the CI daemen directly in reqListener(). Any pros or cons?
proof that an old dog can learn new tricks
Reply


Messages In This Thread
best way to do cross-site request? - by richb201 - 03-06-2018, 06:51 AM
RE: best way to do cross-site request? - by richb201 - 03-07-2018, 12:14 PM



Theme © iAndrew 2016 - Forum software by © MyBB