javascript - how to retrive User name/login name from gmail? -


i using google login custom website. here wrote code it

var soauthserviceendpoint = "https://accounts.google.com/o/oauth2/auth?scope=http://gdata.youtube.com https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email&response_type=token&"; var soauthredirecturl = "http://example.com/testpage/test.html"; var termsandcondurl = "termsandcondition.html"; var soauthclientid = "294016263542.apps.googleusercontent.com";  var sauthenticationurl = soauthserviceendpoint + "redirect_uri=" + soauthredirecturl + "&client_id=" + soauthclientid;   

even got access token using below function

    function fnonload() {       //alert("form loaded");       var saccesstoken = '';       var params = {}, querystring = location.hash.substring(1),regex = /([^&=]+)=([^&]*)/g, m;       while (m = regex.exec(querystring)) {             params[decodeuricomponent(m[1])] = decodeuricomponent(m[2]);         }         if(params.error){             if(params.error == "access_denied"){                 saccesstoken = "access_denied";                 alert(saccesstoken);             }         }else{                 saccesstoken = params.access_token;                 alert(saccesstoken);         }         window.opener.fnauthorisationsuccess(saccesstoken);         window.close();     } 

it's working succesfully , redirect other page want. problem how retrive user login name..?

i using javascript it.

thanks in advance

this can found in documentation.

after application acquires access token , has (if necessary) verified it, can use access token when making requests google api. if https://www.googleapis.com/auth/userinfo.profile scope included in access token request, may use access token acquire user's basic profile information calling userinfo endpoint.

endpoint: https://www.googleapis.com/oauth2/v1/userinfo

returns basic user profile information, including name, userid, gender, birthdate, photo, locale, , timezone. if https://www.googleapis.com/auth/userinfo.email scope present in request, user's email present in response. if email has been verified, there field indicates email verified address.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -