How to generate Vimeo unauthenticated access token?

馋奶兔 提交于 2019-12-05 21:28:05
Dashron

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

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

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