o_auth_api = client.o_auth
OAuthApi
This endpoint is deprecated.
RenewToken
is deprecated. For information about refreshing OAuth access tokens, see
Migrate from Renew to Refresh OAuth Tokens.
Renews an OAuth access token before it expires.
OAuth access tokens besides your application's personal access token expire after 30 days. You can also renew expired tokens within 15 days of their expiration. You cannot renew an access token that has been expired for more than 15 days. Instead, the associated user must re-complete the OAuth flow from the beginning.
Important: The Authorization
header for this endpoint must have the
following format:
Authorization: Client APPLICATION_SECRET
Replace APPLICATION_SECRET
with the application secret on the Credentials
page in the developer dashboard.
ℹ️ Note This endpoint does not require authentication.
def renew_token(self,
client_id,
body,
authorization)
Parameter | Type | Tags | Description |
---|---|---|---|
client_id |
string |
Template, Required | Your application ID, available from the developer dashboard. |
body |
Renew Token Request |
Body, Required | An object containing the fields to POST for the request. See the corresponding object definition for field details. |
authorization |
string |
Header, Required | Client APPLICATION_SECRET |
client_id = 'client_id8'
body = {}
body['access_token'] = 'ACCESS_TOKEN'
authorization = 'Client CLIENT_SECRET'
result = o_auth_api.renew_token(client_id, body, authorization)
if result.is_success():
print(result.body)
elif result.is_error():
print(result.errors)
Revokes an access token generated with the OAuth flow.
If an account has more than one OAuth access token for your application, this endpoint revokes all of them, regardless of which token you specify. When an OAuth access token is revoked, all of the active subscriptions associated with that OAuth token are canceled immediately.
Important: The Authorization
header for this endpoint must have the
following format:
Authorization: Client APPLICATION_SECRET
Replace APPLICATION_SECRET
with the application secret on the OAuth
page in the developer dashboard.
ℹ️ Note This endpoint does not require authentication.
def revoke_token(self,
body,
authorization)
Parameter | Type | Tags | Description |
---|---|---|---|
body |
Revoke Token Request |
Body, Required | An object containing the fields to POST for the request. See the corresponding object definition for field details. |
authorization |
string |
Header, Required | Client APPLICATION_SECRET |
body = {}
body['client_id'] = 'CLIENT_ID'
body['access_token'] = 'ACCESS_TOKEN'
body['merchant_id'] = 'merchant_id6'
body['revoke_only_access_token'] = False
authorization = 'Client CLIENT_SECRET'
result = o_auth_api.revoke_token(body, authorization)
if result.is_success():
print(result.body)
elif result.is_error():
print(result.errors)
Returns an OAuth access token.
The endpoint supports distinct methods of obtaining OAuth access tokens.
Applications specify a method by adding the grant_type
parameter
in the request and also provide relevant information.
Note: Regardless of the method application specified, the endpoint always returns two items; an OAuth access token and a refresh token in the response.
OAuth tokens should only live on secure servers. Application clients should never interact directly with OAuth tokens.
ℹ️ Note This endpoint does not require authentication.
def obtain_token(self,
body)
Parameter | Type | Tags | Description |
---|---|---|---|
body |
Obtain Token Request |
Body, Required | An object containing the fields to POST for the request. See the corresponding object definition for field details. |
body = {}
body['client_id'] = 'APPLICATION_ID'
body['client_secret'] = 'APPLICATION_SECRET'
body['code'] = 'CODE_FROM_AUTHORIZE'
body['redirect_uri'] = 'redirect_uri4'
body['grant_type'] = 'authorization_code'
body['refresh_token'] = 'refresh_token6'
body['migration_token'] = 'migration_token4'
body['scopes'] = ['scopes6', 'scopes7', 'scopes8']
result = o_auth_api.obtain_token(body)
if result.is_success():
print(result.body)
elif result.is_error():
print(result.errors)