How to generate Vimeo unauthenticated access token?

天大地大妈咪最大 提交于 2019-12-07 14:47:49

问题


I am new to Vimeo's api, i am looking for a way to make unauthenticated requests. I find out that i will need to generate unauthenticated access token, but i don't see any option to do that in the Vimeo's apps console. Can anybody help?


回答1:


The app page does not yet support manual construction of unauthenticated access tokens (it's coming!). For now you have to request them programmatically.

Luckily, they don't expire, so you only have to generate it once. Here's a quick walk-through on how to generate this token.

  1. Grab your client id and secret from your app page.
  2. Slam them together with a colon in the middle (eg abcd1234:edgh678)
  3. Base64 encode that whole string (you can find encoders online, plenty of public websites)
  4. Construct the request (you can use curl, a browser tool, or your favorite http request tool).
    • HTTP Method: POST
    • HTTP URL: https://api.vimeo.com/oauth/authorize/client
    • HTTP Headers: Authorization: basic <your base 64 encoded token>
    • Request Body: grant_type=client_credentials&scope=public%20private



回答2:


The auth header is no longer made available through the apps page on the Vimeo Developer site. Instead, you'll need to build the auth header yourself with the token encoded in base64 like so:

'Authorization: basic ' + base64(client_id + ':' + client_secret)

Where client_id and client_secret can be found on your apps page. The final header you should use will look like this:

Authorization: basic xxxxxxxxxxxxxxxxxxxxxxxxx



回答3:


A good way using requests_oauthlib, request, and oauthlib:

client = BackendApplicationClient(client_id=client_id)
auth = requests.auth.HTTPBasicAuth(client_id, client_secret)
oauth = OAuth2Session(client=client)
access_token = oauth.fetch_token(token_url= 'https://api.vimeo.com/oauth/authorize/client', auth=self.auth)


来源:https://stackoverflow.com/questions/33613796/how-to-generate-vimeo-unauthenticated-access-token

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!