c# - I can not get the date of birth from Google Plus API -



c# - I can not get the date of birth from Google Plus API -

i trying user information's google plus api. next link g+ integration. here can information's except dob. must users date of birth.

i have check link , this link. still can not dob.

i seek alter scope.

https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/plus.login

but here getting error.

the remote server returned error: notfound.

please help me dob.. in advance..

update question:

if utilize https://www.googleapis.com/plus/v1/people/me?access_token url getting response:

{ "kind": "plus#person", "etag": "\"vea_b94y77gdggrk7gfnpnolkqw/9l0erpghuny6znrniebs6cghc3y\"", "gender": "male", "emails": [ { "value": "kathir.likes@gmail.com", "type": "account" } ], "objecttype": "person", "id": "1024703xxxxxxxxx93", "displayname": "c. vijay dhas", "name": { "familyname": "dhas", "givenname": "c. vijay" }, "url": "https://plus.google.com/1024703xxxxxxxxx93", "image": { "url": "https://lh3.googleusercontent.com/-xduiqdmkcwa/aaaaaaaaaai/aaaaaaaaaaa /4252rscbv5m/photo.jpg?sz=50", "isdefault": true }, "isplususer": true, "language": "en", "circledbycount": 0, "verified": false }

if utilize https://www.googleapis.com/oauth2/v1/userinfo?access_token url getting response:

{ "id": "1024703xxxxxxxxx93", "email": "kathir.likes@gmail.com", "verified_email": true, "name": "c. vijay dhas", "given_name": "c. vijay", "family_name": "dhas", "link": "https://plus.google.com/1024703xxxxxxxxx93", "picture": "https://lh3.googleusercontent.com/-xduiqdmkcwa/aaaaaaaaaai/aaaaaaaa aaa/4252rscbv5m/photo.jpg", "gender": "male", "locale": "en" }

here entire code:

public partial class googleplusloginpage : phoneapplicationpage { googleplustokens googleplustokens = new googleplustokens(); googleplususerinfo googleplususerinfo = new googleplususerinfo(); string parameters = null; string clientid = "837597087773-9of2t72imted819fr1556t6qoj1ts6h7.apps.googleusercontent.com"; string clientsecret = "u8b7sdw3zmbb_k0afckxae3f"; string redircteduri = "http://localhost"; [datacontract] public class googleplusaccesstoken { [datamember(name = "access_token")] public string accesstoken { get; set; } [datamember(name = "refresh_token")] public string refreshtoken { get; set; } [datamember(name = "expires_in")] public string expiresin { get; set; } [datamember(name = "token_type")] public string tokentype { get; set; } } [datacontract] public class googleplususerprofile { [datamember(name = "id")] public string id { get; set; } [datamember(name = "email")] public string email { get; set; } [datamember(name = "name")] public string name { get; set; } [datamember(name = "given_name")] public string given_name { get; set; } [datamember(name = "family_name")] public string family_name { get; set; } [datamember(name = "link")] public string link { get; set; } [datamember(name = "picture")] public string image { get; set; } [datamember(name = "gender")] public string gender { get; set; } [datamember(name = "birthday")] public string birthday { get; set; } } public googleplusloginpage() { initializecomponent(); this.loaded += new routedeventhandler(googleplus_loginpage_loaded); //load google plus login page } void googleplus_loginpage_loaded(object sender, routedeventargs e) { var url = "https://accounts.google.com/o/oauth2/auth?response_type=code&redirect_uri=" + redircteduri + "&scope=https://www.googleapis.com/auth/userinfo.email%20https://www.googleapis.com/auth/userinfo.profile&client_id=" + clientid; var newurl = "https://accounts.google.com/o/oauth2/auth?response_type=code&redirect_uri=" + redircteduri + "&scope=https://www.googleapis.com/auth/plus.login%20https://www.googleapis.com/auth/userinfo.profile%20https://www.googleapis.com/auth/userinfo.email&client_id=" + clientid; webbrowsergooglepluslogin.navigate(new uri(url, urikind.relativeorabsolute)); } private void webbrowsergooglepluslogin_navigated(object sender, system.windows.navigation.navigationeventargs e) { webbrowsergooglepluslogin.visibility = visibility.visible; } private void webbrowsergooglepluslogin_navigating(object sender, navigatingeventargs e) { if (e.uri.host.equals("localhost")) { webbrowsergooglepluslogin.visibility = visibility.collapsed; e.cancel = true; int pos = e.uri.query.indexof("="); string messagecode = pos > -1 ? e.uri.query.substring(pos + 1) : null; if (messagecode != null) { parameters = "code=" + messagecode + "&client_id=" + clientid + "&client_secret=" + clientsecret + "&redirect_uri=" + redircteduri + "&grant_type=authorization_code"; httpwebrequest webrequest = (httpwebrequest)webrequest.create("https://accounts.google.com/o/oauth2/token"); webrequest.method = "post"; webrequest.contenttype = "application/x-www-form-urlencoded"; webrequest.begingetrequeststream(new asynccallback(getrequeststreamcallback), webrequest); } } } void getrequeststreamcallback(iasyncresult asynchronousresult) { seek { httpwebrequest webrequest = (httpwebrequest)asynchronousresult.asyncstate; stream poststream = webrequest.endgetrequeststream(asynchronousresult); byte[] bytearray = encoding.utf8.getbytes(parameters); poststream.write(bytearray, 0, bytearray.length); poststream.close(); webrequest.begingetresponse(new asynccallback(getresponsecallback), webrequest); } grab (webexception ex) { } } void getresponsecallback(iasyncresult asynchronousresult) { seek { var request = (httpwebrequest)asynchronousresult.asyncstate; using (var resp = (httpwebresponse)request.endgetresponse(asynchronousresult)) { using (var streamresponse = resp.getresponsestream()) { var googleplusserializerdata = new datacontractjsonserializer(typeof(googleplusaccesstoken)); var googleplusprofiledata = googleplusserializerdata.readobject(streamresponse) googleplusaccesstoken; this.dispatcher.begininvoke( (action<googleplusaccesstoken>)((googleplususerdata) => { googleplusdata.accesstoken = googleplustokens.accesstoken = googleplususerdata.accesstoken; googleplustokens.refreshtoken = googleplususerdata.refreshtoken; googleplustokens.expiresin = googleplususerdata.expiresin; googleplustokens.tokentype = googleplususerdata.tokentype; requestforuserprofile(); }), googleplusprofiledata); } } } grab (webexception ex) { console.writeline("error==> " + ex.message); } } void requestforuserprofile() { //var urlprofile = "https://www.googleapis.com/plus/v1/people/me?access_token=" + googleplusdata.accesstoken; var urlprofile = "https://www.googleapis.com/oauth2/v1/userinfo?access_token=" + googleplusdata.accesstoken; webrequest request = webrequest.create(urlprofile); request.begingetresponse(new asynccallback(this.responsecallbackprofile), request); } private void responsecallbackprofile(iasyncresult asynchronousresult) { seek { var request = (httpwebrequest)asynchronousresult.asyncstate; using (var resp = (httpwebresponse)request.endgetresponse(asynchronousresult)) { using (var streamresponse = resp.getresponsestream()) { var googleplusserializerdata = new datacontractjsonserializer(typeof(googleplususerprofile)); var googleplusprofiledata = googleplusserializerdata.readobject(streamresponse) googleplususerprofile; this.dispatcher.begininvoke( (action<googleplususerprofile>)((googleplususerdata) => { googleplusdata.username = googleplususerinfo.username = googleplususerdata.name; googleplusdata.userimage = googleplususerinfo.userpicture = googleplususerdata.picture; if (googleplusdata.userimage == null) { googleplusdata.userimage = googleplususerinfo.userpicture = "https://lh3.googleusercontent.com/-_kvinpt6jti/aaaaaaaaaai/aaaaaaaaaaa/ieaclp4pqbk/photo.jpg"; } googleplususerinfo.userbidthday = googleplususerdata.birthday; googleplusdata.useremail = googleplususerinfo.useremail = googleplususerdata.email; googleplususerinfo.userfamilyname = googleplususerdata.family_name; googleplusdata.usergender = googleplususerinfo.usergender = googleplususerdata.gender; googleplususerinfo.usergivenname = googleplususerdata.given_name; googleplususerinfo.userid = googleplususerdata.id; googleplususerinfo.userlink = googleplususerdata.link; console.writeline("email==> " + googleplususerdata.email); console.writeline("birthday==> " + googleplususerdata.birthday); deployment.current.dispatcher.begininvoke(() => { //logout(); }); }), googleplusprofiledata); } } } grab (webexception ex) { } } void logout() { var url = "http://accounts.google.com/logout"; webbrowsergooglepluslogin.navigate(new uri(url, urikind.relativeorabsolute)); navigationservice.goback(); } }

the article on nokia rather misleading doing. in particular, although says next method calls "the google+ api", not. google+ phone call commented out , phone call older (and deprecated) userinfo api:

//request user prifile void requestforuserprofile() { // var urlprofile = "https://www.googleapis.com/plus/v1/people/me?access_token=" + thisapp.accesstoken; var urlprofile = "https://www.googleapis.com/oauth2/v1/userinfo?access_token="+thisapp.accesstoken; // web request user profile webrequest request = webrequest.create(urlprofile); request.begingetresponse(new asynccallback(this.responsecallbackprofile), request); }

if comment out urlprofile "userinfo" in path , uncomment 1 "plus/v1/people", have improve luck.

if doesn't work, may want update original question show code using, you're trying do, , error message you're getting generated.

c# windows-phone-7 google-plus

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -