public static DoAuth ( IWin32Window owner, |
||
owner | IWin32Window | 親ウィンドウ |
authUri | 認証URL | |
리턴 | string |
private UserAccount PinAuth() { this.tw.Initialize("", "", "", 0); var pinPageUrl = ""; var err = this.tw.StartAuthentication(ref pinPageUrl); if (!string.IsNullOrEmpty(err)) { throw new WebApiException(err); } var pin = AuthDialog.DoAuth(this, pinPageUrl); if (string.IsNullOrEmpty(pin)) { return(null); // キャンセルされた場合 } var err2 = this.tw.Authenticate(pin); if (!string.IsNullOrEmpty(err2)) { throw new WebApiException(err2); } return(new UserAccount { Username = this.tw.Username, UserId = this.tw.UserId, Token = this.tw.AccessToken, TokenSecret = this.tw.AccessTokenSecret, }); }
private async Task <UserAccount> PinAuth() { var requestToken = await TwitterApiConnection.GetRequestTokenAsync(); var pinPageUrl = TwitterApiConnection.GetAuthorizeUri(requestToken); var pin = AuthDialog.DoAuth(this, pinPageUrl); if (string.IsNullOrEmpty(pin)) { return(null); // キャンセルされた場合 } var accessTokenResponse = await TwitterApiConnection.GetAccessTokenAsync(requestToken, pin); return(new UserAccount { Username = accessTokenResponse["screen_name"], UserId = long.Parse(accessTokenResponse["user_id"]), Token = accessTokenResponse["oauth_token"], TokenSecret = accessTokenResponse["oauth_token_secret"], }); }