Пример #1
0
 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);
 }
Пример #2
0
 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;
 }
Пример #3
0
 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));
 }
Пример #4
0
 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);
     }
 }
Пример #6
0
 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);
            }
        }
Пример #8
0
 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));
 }
Пример #9
0
 public SpecificLoginServiceViewModel()
 {
     this.LoginCommand  = new RelayCommand(this.Login);
     this.oAuth2Service = this.GetOAuth2Service();
 }
 public SpecificLoginServiceViewModel()
 {
     this.LoginCommand = new RelayCommand(this.Login);
     this.oAuth2Service = this.GetOAuth2Service();
 }