public async Task <string> RequestToken(OAuth2ServiceBase service) { //try //{ // WebAuthenticationResult webAuthenticationResult = // await // WebAuthenticationBroker.AuthenticateAsync(this.GetWebAuthenticationOptions(service), service.AuthorizationCodeStartUri, service.AuthorizationCodeEndUrl); // if (webAuthenticationResult.ResponseStatus == WebAuthenticationStatus.Success) // { // return this.ParseAuthorizationCodeFrom(webAuthenticationResult.ResponseData); // } // else if (webAuthenticationResult.ResponseStatus == WebAuthenticationStatus.ErrorHttp) // { // // do something when the request failed // } // else // { // throw new NotSupportedException(); // } //} //catch (Exception) //{ // // do something when an exception occurred //} return(null); }
public async Task<string> RequestToken(OAuth2ServiceBase service) { try { WebAuthenticationResult webAuthenticationResult = await WebAuthenticationBroker.AuthenticateAsync(this.GetWebAuthenticationOptions(service), service.AuthorizationCodeStartUri, service.AuthorizationCodeEndUrl); if (webAuthenticationResult.ResponseStatus == WebAuthenticationStatus.Success) { return this.ParseAuthorizationCodeFrom(webAuthenticationResult.ResponseData); } else if (webAuthenticationResult.ResponseStatus == WebAuthenticationStatus.ErrorHttp) { // do something when the request failed } else { throw new NotSupportedException(); } } catch (Exception) { // do something when an exception occurred } return null; }
public void Store(UserInfo user, OAuth2ServiceBase service) { this.UserInfo = user; this.OAuth2Service = service; StoreSetting("OAuth2UserInfo", JsonConvert.SerializeObject(UserInfo, new JsonSerializerSettings(){ContractResolver = new DefaultContractResolver(){SerializeCompilerGeneratedMembers = true}})); StoreSetting("OAuth2Service", JsonConvert.SerializeObject(OAuth2Service)); }
private WebAuthenticationOptions GetWebAuthenticationOptions(OAuth2ServiceBase service) { if (service.GetType() == typeof(GoogleOAuth2Service)) { return WebAuthenticationOptions.UseTitle; } return WebAuthenticationOptions.None; }
private async Task HandleLogin(OAuth2ServiceBase service) { this.User = await service.Login(); if (this.User.IsValid) { AuthorizedUser.Instance.Store(this.User, service); } }
private WebAuthenticationOptions GetWebAuthenticationOptions(OAuth2ServiceBase service) { if (service.GetType() == typeof(GoogleOAuth2Service)) { return(WebAuthenticationOptions.UseTitle); } return(WebAuthenticationOptions.None); }
public void Store(UserInfo user, OAuth2ServiceBase service) { this.UserInfo = user; this.OAuth2Service = service; StoreSetting("OAuth2UserInfo", JsonConvert.SerializeObject(UserInfo, new JsonSerializerSettings() { ContractResolver = new DefaultContractResolver() { SerializeCompilerGeneratedMembers = true } })); StoreSetting("OAuth2Service", JsonConvert.SerializeObject(OAuth2Service)); }
public SpecificLoginServiceViewModel() { this.LoginCommand = new RelayCommand(this.Login); this.oAuth2Service = this.GetOAuth2Service(); }