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.
Error:
UnauthorizedClientError: (unauthorized_client) The client is not authorized to use the provided grant type. Configured grant types: [authorization_code, implicit, refresh_token].
Hello MKTG_Team,
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.
OAuth2 Overview:
https://developer.constantcontact.com/api_guide/auth_overview.html
Authorization Code Flow:
https://developer.constantcontact.com/api_guide/server_flow.html
Please have a look and let us know if you have any other questions!
Regards,
Support Tips
"There's a multitude of ways to engage your audience through us using your social platforms - via ads, social post metrics, email links, and more! " - Will
See ArticleSupport Tips
"Target your most engaged contacts by creating a segment. Create a special offer or show your appreciation!" - Caitlin
See ArticleSupport Tips
"Greet new contacts with one or more automated Welcome Emails depending on their interests or your business goals." - Nick
See Article