Пример #1
0
 public OAuth2AuthFilter(
     OAuth2AccessToken accessToken,
     IHttpFilter filter)
 {
     this.accessToken = accessToken;
     this.filter      = filter;
 }
Пример #2
0
        private async void OAuthGetToken_SendRequest()
        {
            var filter     = new OAuthGetTokenAuthFilter(ConsumerKey, ConsumerSecret, new HttpBaseProtocolFilter());
            var httpClient = new HttpClient(filter);

            var body        = "grant_type=client_credentials";
            var encoding    = Windows.Storage.Streams.UnicodeEncoding.Utf8;
            var contentType = "application/x-www-form-urlencoded";
            var content     = new HttpStringContent(body, encoding, contentType);

            var response = await httpClient.PostAsync(new Uri(OAuth2TokenUrl), content);

            var result = await response.Content.ReadAsStringAsync();

            this.accessToken = JsonConvert.DeserializeObject <OAuth2AccessToken>(result);

            this.WriteLog("TokenType={0}, AccessToken={1}", accessToken.token_type, accessToken.access_token);
        }
Пример #3
0
 public MainPage()
 {
     this.InitializeComponent();
     this.synchronizationContext = System.Threading.SynchronizationContext.Current;
     this.accessToken            = null;
 }