public AcquireAccessToken ( string uri, string method, string pin, string user_agent ) : |
||
uri | string | |
method | string | |
pin | string | |
user_agent | string | |
return |
public string AuthorizeApp(string pin) { OAuthResponse accessToken = OAuth.AcquireAccessToken("http://api.discogs.com/oauth/access_token", "POST", pin, _UserAgent); var search = "http://api.discogs.com/oauth/identity"; var authHeader = OAuth.GenerateAuthzHeader(search, "GET"); return(authHeader); }
public void AcquireAccessToken() { string code = (string)Settings.Default["EtsyVerificationCode"]; var response = oAuth.AcquireAccessToken(ACCESS_TOKEN_URI, "GET", code); Settings.Default.EtsyAccessToken = response["oauth_token"]; Settings.Default.EtsyAccessTokenSecret = response["oauth_token_secret"]; Settings.Default.Save(); oAuth["token"] = response["oauth_token"]; oAuth["token_secret"] = response["oauth_token_secret"]; }
public async Task<bool?> Init(MetroWindow win) { try { parentWindow = win as MainWindow; authMgr = new Manager(); authMgr["consumer_key"] = ConsumerKey; authMgr["consumer_secret"] = ConsumerSecret; authMgr.AcquireRequestToken(RequestTokenURL, "POST"); MetroDialogSettings settings = new MetroDialogSettings() { AnimateHide = true, AnimateShow = true, AffirmativeButtonText = "확인", NegativeButtonText = "종료" }; MessageDialogResult result = await DialogManager.ShowMessageAsync(parentWindow, "인증", "인증을 위해 웹브라우저를 통해 트위터에 로그인합니다.", MessageDialogStyle.AffirmativeAndNegative, settings); if (result == MessageDialogResult.Affirmative) { System.Diagnostics.Process.Start($"{RequestPinURL}{authMgr["token"]}"); settings = new MetroDialogSettings() { AnimateHide = true, AnimateShow = true, AffirmativeButtonText = "인증", NegativeButtonText = "취소 및 종료" }; string pin = await DialogManager.ShowInputAsync(parentWindow, "PIN", "웹브라우저 상에 표시된 PIN을 입력합니다.", settings); try { authMgr.AcquireAccessToken(AccessTokenURL, "POST", pin); } catch(Exception ex) { parentWindow.Close(); } IsInit = true; // Get Screen Name dynamic obj = await GetJson("https://api.twitter.com/1.1/account/settings.json", "GET"); string name = obj.screen_name; // GetProfile dynamic json = await GetJson($"https://api.twitter.com/1.1/users/show.json?screen_name={name}", "GET"); parentWindow.UserNameBlock.Text = json.name; parentWindow.ScreenNameBlock.Text = $"@{json.screen_name}"; parentWindow.ProfileDescBlock.Text = json.description; string imageUrl = json.profile_image_url; ProfileImage = new BitmapImage(); ProfileImage.BeginInit(); ProfileImage.UriSource = new Uri(imageUrl.Replace("_normal", "")); ProfileImage.DownloadCompleted += (s, ev) => OnPropertyChanged("ProfileImage"); ProfileImage.EndInit(); } else { parentWindow.Close(); } return IsInit; } catch (Exception e) { await DialogManager.ShowMessageAsync(parentWindow, "Error", $"= Message{e.Message}\n\n= Stack Trace\n{e.StackTrace}"); IsInit = false; return false; } }