コード例 #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
ファイル: AuthorizedUser.cs プロジェクト: projecteon/OAuth2
 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;
 }
コード例 #5
0
 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);
 }
コード例 #7
0
        private async Task HandleLogin(OAuth2ServiceBase service)
        {
            this.User = await service.Login();

            if (this.User.IsValid)
            {
                AuthorizedUser.Instance.Store(this.User, service);
            }
        }
コード例 #8
0
ファイル: AuthorizedUser.cs プロジェクト: projecteon/OAuth2
 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();
 }
コード例 #10
0
 public SpecificLoginServiceViewModel()
 {
     this.LoginCommand = new RelayCommand(this.Login);
     this.oAuth2Service = this.GetOAuth2Service();
 }