The response from an OAuth2 Token request.
Наследование: IOAuth2Token
Пример #1
0
        public void SwitchClient_SetMashapeClientAndOAuth2TokenThenImgurClient_HeadersEqual()
        {
            var oAuth2Token = new OAuth2Token("access_token", "refresh_token", "bearer", "11345", "bob", 2419200);
            var client = new ImgurClient("123", "1234", oAuth2Token);
            var mashapeClient = new MashapeClient("123444", "567567", "12354564");
            var endpoint = new MockEndpoint(mashapeClient);

            Assert.True(endpoint.ApiClient is IMashapeClient);

            var authHeader = endpoint.HttpClient.DefaultRequestHeaders.GetValues("Authorization").First();

            Assert.Equal("Client-ID 123444", authHeader);

            endpoint.SwitchClient(client);
            authHeader = endpoint.HttpClient.DefaultRequestHeaders.GetValues("Authorization").First();

            Assert.True(endpoint.ApiClient is IImgurClient);
            Assert.Equal("Bearer access_token", authHeader);
        }
Пример #2
0
 public void HttpClientWithMashapeClientAndOAuth2Token_SetByConstructor_HeadersEqual()
 {
     var oAuth2Token = new OAuth2Token("access_token", "refresh_token", "bearer", "11345", "bob", 2419200);
     var client = new MashapeClient("123", "1234", "1234567", oAuth2Token);
     var endpoint = new MockEndpoint(client);
     var authHeader = endpoint.HttpClient.DefaultRequestHeaders.GetValues("Authorization").First();
     var mashapeHeaders = endpoint.HttpClient.DefaultRequestHeaders.GetValues("X-Mashape-Key").First();
     var accept = endpoint.HttpClient.DefaultRequestHeaders.Accept.First();
     Assert.Equal("Bearer access_token", authHeader);
     Assert.Equal("1234567", mashapeHeaders);
     Assert.Equal("application/json", accept.MediaType);
 }