Vimeo writing Making Requests
After you have either an authenticated or unauthenticated access token (as explained in the preceding sections), send the access token through the authorization header:
curl -H "Authorization: Bearer <OAUTH_TOKEN>" https://api.vimeo.com
and it's work, but in my application I can't be authorized
RestClient.post 'https://api.vimeo.com/oauth/authorize/client', {grant_type: 'client_credentials', client_id: Rails.application.secrets.vimeo_id, client_secret: Rails.application.secrets.vimeo_secret}
RestClient::Unauthorized: 401 Unauthorized
Please somebody tell me how I can do authenticated to success...
You mentioned different requests. To get an access toket with RestClient do:
r = RestClient::Request.execute(method: :post,
url: "https://api.vimeo.com/oauth/authorize/client",
payload: {grant_type: "client_credentials"},
user: VIMEO_CLIENT_ID,
password: VIMEO_CLIENT_SECRET)
=> "{\"access_token\":\"scrt12334\",\"token_type\":\"bearer\",\"scope\":\"public\",\"app\":{\"name\":\"test\",\"uri\":\"/apps/79881\"}}"
token = JSON.parse(r)['access_token']
=> "scrt12334"
And then get an API endpoints with Bearer authorization:
methods = RestClient::Request.execute(method: :get, url: "https://api.vimeo.com", payload: {}, headers: {"Authorization"=>"Bearer #{token}"})
=> "{\"endpoints\":[{\"path\":\"https://api.vimeo.com/\",\"methods\":[\"GET\",\"OPTIONS\"]},....
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.