Created
February 19, 2020 17:20
-
-
Save hadrienblanc/cba7c90f768b37d40e3366da6b6df33a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rest-client' | |
require 'json' | |
client_id = '42f5e************************' | |
client_secret = 'secret-b42-************************' | |
begin | |
response = RestClient.post('www.my_app.com/oauth/token', { | |
grant_type: 'client_credentials', | |
client_id: client_id, | |
client_secret: client_secret | |
}) { |response, request, result| | |
case response.code | |
when 301, 302, 307 | |
response.follow_redirection | |
else | |
response.return! | |
end | |
} | |
puts response.body | |
rescue RestClient::ExceptionWithResponse => e | |
puts e.response | |
end | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rest-client' | |
require 'json' | |
access_tokken = "bearer_token_********" | |
access_tokken = "Bearer #{access_tokken}" | |
url = "my_secret_ressource_endpoint/31" | |
response = RestClient.get(url, { | |
Authorization: access_tokken | |
}) | |
puts response.body |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment