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

c++ - llvm function pass ReplaceInstWithInst malloc -

java.lang.NoClassDefFoundError When Creating New Android Project -

Decoding a Python 2 `tempfile` with python-future -