public void ImgurImplicitFlowCheck() { string token = OAuth2Helper.GetImgurTokenImplicit("0f624d4e6985af4", "TestTaskZel", "Test1234Test"); RestClient client = new RestClient("https://api.imgur.com/3/account/me/images") { Authenticator = new OAuth2AuthorizationRequestHeaderAuthenticator(token, bearerTokenType) }; RestRequest getRequest = new RestRequest(Method.GET); IRestResponse getResponse = client.Execute(getRequest); JSchema schema = JSchema.Parse(@"{ 'type': 'object', 'properties': { 'data': {'type':'array'}, 'success': {'type':'boolean'}, 'status': {'type':'number'} } }"); JObject result = JObject.Parse(getResponse.Content); bool valid = result.IsValid(schema); Assert.True(valid, "Result is not valid"); }
public void FormStackAuthorizationCodeFlowCheck() { string token = OAuth2Helper.GetFormStackTokenThrowAuthCode("15099", "login", "password"); RestClient client = new RestClient("https://www.formstack.com/api/v2/form.json") { Authenticator = new OAuth2AuthorizationRequestHeaderAuthenticator(token, bearerTokenType) }; RestRequest getRequest = new RestRequest(Method.GET); IRestResponse getResponse = client.Execute(getRequest); JSchema schema = JSchema.Parse(@"{ 'type': 'object', 'properties': { 'forms': {'type':'array'}, 'total': {'type':'number'} } }"); JObject result = JObject.Parse(getResponse.Content); bool valid = result.IsValid(schema); Assert.True(valid, "Result is not valid"); }
public void ImgurAuthorizationCodeFlowCheck() { string token = OAuth2Helper.GetImgurTokenThrowCode("6882d17e7f88b68", "06b9984082706750a1182b1f16e78e650381b416", "TestTaskZel", "Test1234Test"); RestClient client = new RestClient("https://api.imgur.com/3/account/me/available_avatars") { Authenticator = new OAuth2AuthorizationRequestHeaderAuthenticator(token, bearerTokenType) }; RestRequest getRequest = new RestRequest(Method.GET); IRestResponse getResponse = client.Execute(getRequest); JSchema schema = JSchema.Parse(@"{ 'type': 'object', 'properties': { 'data': {'type':'object'}, 'success': {'type':'boolean'}, 'status': {'type':'number'} } }"); JObject result = JObject.Parse(getResponse.Content); bool valid = result.IsValid(schema); Assert.True(valid, "Result is not valid"); }
public void SpotifyClientCredentialsFlowCheck() { string token = OAuth2Helper.GetSpotifyTokenThrowClientCredentials("ffa4d3f9b2b04aa5b3791716ab943218", "7487562733a049f4b38dc407cc4156ee"); RestClient client = new RestClient("https://api.spotify.com/v1/search?type=artist&q=Eminem") { Authenticator = new OAuth2AuthorizationRequestHeaderAuthenticator(token, bearerTokenType) }; RestRequest getRequest = new RestRequest(Method.GET); IRestResponse getResponse = client.Execute(getRequest); JSchema schema = JSchema.Parse(@"{ 'type': 'object', 'properties': { 'artists': { 'type':'object', 'properties':{ 'href': {'type':'string'}, 'items': { 'type':'array', 'items':{ 'type':'object' } }, 'limit': {'type':'number'}, 'offset': {'type':'number'}, 'total': {'type':'number'} } } } }"); JObject result = JObject.Parse(getResponse.Content); bool valid = result.IsValid(schema); Assert.True(valid, "Result is not valid"); }
public void BitlyResourceOwnerPasswordFlowCheck() { string token = OAuth2Helper.GetBitlyTokenThrowResourceOwnerPassword("967be650896308c8dea967f02a08253a261abdeb", "9de9e38f5ac92985ba91e2fae0f5ba187ce01e49", "TestTaskZel", "Test1234Test"); RestClient client = new RestClient("https://api-ssl.bitly.com"); RestRequest getRequest = new RestRequest($"/v3/link/info?access_token={token}&link=http%3A%2F%2Fbit.ly%2FMwSGaQ", Method.GET); IRestResponse getResponse = client.Execute(getRequest); JSchema schema = JSchema.Parse(@"{ 'type': 'object', 'properties': { 'status_code': {'type':'number'}, 'data': {'type':'object'}, 'status_txt': {'type':'string'} } }"); JObject result = JObject.Parse(getResponse.Content); bool valid = result.IsValid(schema); Assert.True(valid, "Result is not valid"); }