python import requests from requests_oauthlib import OAuth2Session client_id = 'your_client_id' client_secret = 'your_client_secret' scope = ['scope1', 'scope2'] oauth2_session = OAuth2Session(client_id, scope=scope) authorization_url, state = oauth2_session.authorization_url('authorization_endpoint') redirect_response = 'http://example.com/callback?code=code' token = oauth2_session.fetch_token('token_endpoint', authorization_response=redirect_response, client_secret=client_secret) session = OAuth2Session(client_id, token=token) response = session.get('protected_resource_endpoint')


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