c# - Authenticatioin of user in wp8 app using google login -


i want authenticate user wp8 app using users google login credentials. can profile info of user. found 2 articles in web source code. unable want.

first code i've found in link. after getting authentication code didn't have code profile. may not understand.

second code i've found in link. following mvvm pattern, totally blank understand code.

if have used properly, please me. want after getting client id , client secret in app user's profile info. helps appreciated. in advance.

here code

protected override void onnavigatedto(navigationeventargs e) 

{

base.onnavigatedto(e);    idictionary<string, string> parameters = this.navigationcontext.querystring;    string authendpoint = parameters["authendpoint"];  string clientid = parameters["clientid"];  string scope = parameters["scope"];    string uri = string.format("{0}?response_type=code&client_id={1}&redirect_uri={2}&scope={3}",      authendpoint,      clientid,      "urn:ietf:wg:oauth:2.0:oob",      scope);    webbrowser.navigate(new uri(uri, urikind.absolute)); 

}

private async void layoutroot_loaded(object sender, routedeventargs e) 

{

if(!app.loggedin)  {      oauthauthorization authorization = new oauthauthorization(      "https://accounts.google.com/o/oauth2/auth",      "https://accounts.google.com/o/oauth2/token");      tokenpair tokenpair = await authorization.authorize(          "your_client_id",          "client_secret",          new string[] { googlescopes.userinfoemail });        // request new access token using refresh token (when access token expired)      tokenpair refreshtokenpair = await authorization.refreshaccesstoken(          "your_client_id",          "client_secret",          tokenpair.refreshtoken);  } 

}

what after getting access token?

this code allows view profile details:

private void loadprofile(string access_token) {     debug.writeline("loading profile");      restclient client = new restclient("https://www.googleapis.com");     client.authenticator = new oauth2authorizationrequestheaderauthenticator(access_token);     var request = new restrequest("/oauth2/v1/userinfo", method.get);     client.executeasync<profile>(request, profileloaded); } private void profileloaded(irestresponse<profile> response) {     profile = response.data; } 

just pass in access_token got prior code , data should contained in response.data


Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

php - phpWord - Tables with borders in headers/footers -