python import requests from requests_oauthlib import OAuth2Session from oauthlib.oauth2 import BackendApplicationClient python client_id = 'your-client-id' client_secret = 'your-client-secret' authorization_endpoint = 'https://example.com/authorization' token_endpoint = 'https://example.com/token' python oauth = OAuth2Session(client=BackendApplicationClient(client_id=client_id)) token = oauth.fetch_token(token_url=token_endpoint, client_id=client_id, client_secret=client_secret) python response = oauth.get('https://api.example.com/resource', headers={'Authorization': 'Bearer ' + token['access_token']}) print(response.json())


上一篇:
下一篇:
切换中文