Am trying to access the below API to get access token but am getting error mentioned below the code snippet:
from requests.auth import HTTPBasicAuth from oauthlib.oauth2 import BackendApplicationClient from requests_oauthlib import OAuth2Session auth_token_url = "https://authz.constantcontact.com/oauth2/default/v1/token" client = BackendApplicationClient(client_id=client_id) oauth = OAuth2Session(client=client) basic_auth = HTTPBasicAuth(client_id, client_secret) token = oauth.fetch_token(token_url=auth_token_url, auth=basic_auth)
What am i missing here? I need to get access token to make api call to below url:
Is there a way to generate access token that doesn't expire as am trying to build a data pipeline using this API call.
UnauthorizedClientError: (unauthorized_client) The client is not authorized to use the provided grant type. Configured grant types: [authorization_code, implicit, refresh_token].
Thank you for reaching out to Constant Contact API Developer Support. My team is here to assist outside software developers with questions about building into Constant Contact's API.
After reviewing the logs for your keys, I found that the grant_type value being used in your token requests is “client_credentials”. If you are trying to use the authorization code flow, the required grant_type is “authorization_code”.
Our access tokens expire after 1440 minutes (86,400 seconds) but your application can utilize refresh tokens to extend the lifespan of an access token by exchanging it for a new set of access and refresh tokens. For more information on this process I am including overview documentation for our OAuth2 authentication and the Authorization Code flow below.
Authorization Code Flow:
Please have a look and let us know if you have any other questions!
View API documentation, code samples, get your API key.Visit Page
Join our list to be notified of new features and updates to our V3 API.Sign Up