OAuth2 Authorization Code Flow | Constant Contact Developer Portal (2024)

Describes the Authorization Code Flow.

Use the OAuth2 Authorization Code Flow for traditional web applications (your application runs on a web server and executes on a server) and is able to safely store the client secret. Being a redirect-based flow, the client must be able to interact with the resource owner’s user-agent (typically a web browser) and receive incoming requests (via redirect) from the Constant Contact Authorization Server.

Because the Authorization Code Flow passes the access token directly to the web server that hosts the client application rather than to the user’s web browser, it is considered the most secure OAuth2 flow.

Using the Authorization Code Flow, you create an authorization request to allow users to authorize your application to use their Constant Contact data. After users grant your application access to their data, Constant Contact sends you an access token that you use to make V3 API requests, and a refresh token. The refresh token is used to extend the life of the access token without requiring users to re-authenticate their Constant Contact account and reauthorize your application to use their data. When you get a new access token, you should always decode it to validate the access token claims and expiration.

In order to use the Authorization Code Flow, you must first create and configure a V3 API application. For more information, see Create an Application Integration.

To use the Authorization Code Flow for authorization, complete the steps that follow.

Create the authorization request used to direct users to Constant Contact to authenticate their user account and authorize your application to access their Constant Contact data.

To create an authorization request, make a GET call to the authorization endpoint https://authz.constantcontact.com/oauth2/default/v1/authorize and include all required request query parameters.

For example, the following shows an encoded URL authorization request:

https://authz.constantcontact.com/oauth2/default/v1/authorize?client_id={your_client_id}&redirect_uri=https%3A%2F%2Flocalhost%3A8888&response_type=code&scope=contact_data%20campaign_data%20offline_access&state=235o250eddsdff

Request Parameters

URL encode all request parameters.

  • client_idRequired. The API key for your application. You can view the API keys for all of your applications or create a new application on the My Applications page.

  • redirect_uriRequired. Specify the absolute URI that you want Constant Contact to use when redirecting a user to your application. After a user authorizes your application, Constant Contact redirects the user to your application and appends the authorization code and state (and optionally the scope) values to the URI as query parameters. Wildcards are not supported except at the domain root level. For more information, see the Authentication Overview page.

  • response_typeRequired. This flow uses code as the value to request an authorization code from Constant Contact.

  • state - Required. To prevent cross-site request forgery, specify the arbitrary state string value you want to use to uniquely identify a user’s session.

  • scopeOptional. A list of the scopes that your application requires. The V3 API currently supports the account_read, account_update, contact_data, offline_access, and campaign_data scopes. Scope names must be space-delimited. For example: {contact_data%20campaign_data%20offline_access}.

    The offline_access scope is required for returning refresh tokens. For more information on scopes and the specific scopes required by each V3 API endpoint, see the Scopes Overview page.

  • nonceOptional. For the purpose of mitigating replay attacks, specify the string value to use to associate a client session with an id_token. The id_token includes information (claims) about the user and, if specified, the nonce value. The id_token is encoded as a JWT and returned in the response when you request an access token. To verify the nonce string value, decode the id_token.

PHP JAVA

/* * This function can be used to generate the URL an account owner would use to allow your app to access their account. * After visiting the URL, the account owner is prompted to log in and allow your app to access their account. * The account owner is then redirected to your redirect URL with the authorization code and state appended as query parameters. e.g.: * http://localhost:8888/?code={authorization_code}&state={encoded_string_value(s)} *//** * @param $redirectURI - URL Encoded Redirect URI * @param $clientId - API Key * @param $scope - URL encoded, plus sign delimited list of scopes that your application requires. The 'offline_access' scope needed to request a refresh token is added by default. * @param $state - Arbitrary string value(s) to verify response and preserve application state * @return string - Full Authorization URL */function getAuthorizationURL($clientId, $redirectURI, $scope, $state) { // Create authorization URL $baseURL = "https://authz.constantcontact.com/oauth2/default/v1/authorize"; $authURL = $baseURL . "?client_id=" . $clientId . "&scope=" . $scope . "+offline_access&response_type=code&state=" . $state . "&redirect_uri=" . $redirectURI; return $authURL;}
/* * This function can be used to generate the URL an account owner would use to * allow your app to access their account. * After visiting the URL, the account owner is prompted to log in and allow * your app to access their account. * The account owner is then redirected to your redirect URL with the * authorization code and state appended as query parameters. e.g.: * http://localhost:8888/?code={authorization_code}&state={encoded_string_value(s)} *//** * @param redirectUri - URL Encoded Redirect URI * @param clientId - API Key * @param scope - URL encoded, plus sign delimited list of scopes that * your application requires. The 'offline_access' scope * needed to request a refresh token is added by default. * @param state - Arbitrary string value(s) to verify response and * preserve application state * @return - Full Authentication URL */public String getAuthorizationURL(String redirectUri, String clientId, String scope, String state) { // Create authorization URL StringBuilder authUrl = new StringBuilder() .append("https://authz.constantcontact.com/oauth2/default/v1/authorize") .append("?client_id=") .append(clientId) .append("&scope=") .append(scope) .append("+offline_access") .append("&response_type=code") .append("&redirect_uri=") .append(redirectUri) .append("&state=") .append(state); return authUrl.toString();}

Add the authorization request to your application to direct users to Constant Constant where they are prompted to sign in to authenticate their user account. Next, Constant Contact displays the Permission Request screen allowing the user to authorize your application to access the Constant Contact data that your application requests.

OAuth2 Authorization Code Flow | Constant Contact Developer Portal (1)

After a user successfully grants your application access to their data, Constant Contact redirects the user to your chosen redirect URI and appends the authorization code and state values (and optional scope values), as query parameters. For example:

 `http://localhost:8888/?code=lN1WhAHX9ooSIfuhy0LzWJhv713O&state=235o250eddsdff&scope=contact_data`

Make a POST request to the https://authz.constantcontact.com/oauth2/default/v1/token token endpoint to exchange the authorization code for an access and refresh token.

Request Parameters

  • codeRequired. Enter the authorization code that Constant Contact returns to your redirect URI in the authorization request response. Authorization codes expire after 5 minutes (300 seconds).

  • redirect_uriRequired. The absolute URI that Constant Contact redirects the user to after they grant access to your application. Wildcards are not supported except at the domain root level. For more information, see the Create an Application Integration page.

  • grant_typeRequired. The value is always authorization_code. This value specifies that the request is part of the Authorization Code Flow.

Header Formats

In the header, specify the preferred response formats to return as follows:

  • "Accept", "application/json"
  • "Content-Type", "application/x-www-form-urlencoded"

Authentication

This request requires basic authentication. Base64 encode the string client_id:client_secret and provide it in the Authorization header of the request. The client_id is the API Key for your application. You can obtain the client_id and client_secret values for your application on the My Applications page.

For example:

`Authorization: Basic MjdlOPBkNjktUmQ4MY00MGUwLWVmZmYtODRjZjM2`

Example Request

PHP JAVA cURL

curl -X POST -i -H "Content-Type: application/x-www-form-urlencoded" -H "Authorization: Basic {base64 client_id:client_secret}" "https://authz.constantcontact.com/oauth2/default/v1/token?code={authorization_code}&redirect_uri={redirect_uri}&grant_type=authorization_code"
/* * This function can be used to exchange an authorization code for an access token. * Make this call by passing in the code present when the account owner is redirected back to you. * The response will contain an 'access_token' and 'refresh_token' *//** * @param $redirectURI - URL Encoded Redirect URI * @param $clientId - API Key * @param $clientSecret - API Secret * @param $code - Authorization Code * @return string - JSON String of results */function getAccessToken($redirectURI, $clientId, $clientSecret, $code) { // Use cURL to get access token and refresh token $ch = curl_init(); // Define base URL $base = 'https://authz.constantcontact.com/oauth2/default/v1/token'; // Create full request URL $url = $base . '?code=' . $code . '&redirect_uri=' . $redirectURI . '&grant_type=authorization_code'; curl_setopt($ch, CURLOPT_URL, $url); // Set authorization header // Make string of "API_KEY:SECRET" $auth = $clientId . ':' . $clientSecret; // Base64 encode it $credentials = base64_encode($auth); // Create and set the Authorization header to use the encoded credentials, and set the Content-Type header $authorization = 'Authorization: Basic ' . $credentials; curl_setopt($ch, CURLOPT_HTTPHEADER, array($authorization, 'Content-Type: application/x-www-form-urlencoded')); // Set method and to expect response curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // Make the call $result = curl_exec($ch); curl_close($ch); return $result;}
/* * This method can be used to exchange an authorization code for an access token. * Make this call by passing in the code present when the account owner is * redirected back to you after authenticating. * The response will contain an 'access_token' and 'refresh_token' *//** * @param redirectUri - URL Encoded Redirect URI * @param clientId - API Key * @param clientSecret - API Secret * @param authCode - Authorization Code * @return - JSON string containing an access_token and a refresh_token * @throws InterruptedException * @throws IOException * @throws URISyntaxException */public static String getAccessToken(String redirectUri, String clientId, String clientSecret, String authCode) throws IOException, InterruptedException, URISyntaxException{ // Make authorization header with API Key:API Secret and Base64 encode String credentials = clientId + ":" + clientSecret; String authHeader = "Basic " + Base64.getEncoder().encodeToString(credentials.getBytes()); // Create request URL StringBuilder requestBuilder = new StringBuilder() .append("https://authz.constantcontact.com/oauth2/default/v1/token") .append("?code=") .append(authCode) .append("&redirect_uri=") .append(redirectUri) .append("&grant_type=authorization_code"); URI requestUri = new URI(requestBuilder.toString()); HttpClient httpClient = HttpClient.newHttpClient(); HttpRequest request = HttpRequest.newBuilder(requestUri) .POST(HttpRequest.BodyPublishers.ofString("")) .header("Accept","application/json") .header("Content-Type", "application/x-www-form-urlencoded") .header("Authorization", authHeader) .build(); HttpResponse<String> httpResponse = httpClient.send(request, HttpResponse.BodyHandlers.ofString()); return httpResponse.body();}

Example Response

{ "token_type": "Bearer", "expires_in": 28800, "access_token": "eyJraWQiOiIzSDdLVVpkSDlyNTh6RVVDSzNYMlR1b2o0SjV0eldWUF9FRUxQTDd6X3hjIiwiYWxnIjoiUlMyNTYifQ.eyJ2ZXIiOjEsImp0aSI6IkFULkZ6YUUtTVFFb2dKQ1VzZlhSUGtBZldobDllckJndVlYRWphOGFXd1RyRzgiLCJpc3MiOiJodHRwczovL2lkZW50aXR5LmNvbnN0YW50Y29udGFjdC5jb20vb2F1dGgyL2F1czFsbTNyeTltRjd4MkphMGg4IiwiYXVkIjoiaHR0cHM6Ly9hcGkuY2MuZW1haWwvdjMiLCJpYXQiOjE2NDQ0Mjc3NzMsImV4cCI6MTY0NDQ1NjU3MywiY2lkIjoiY2M5NGMyZDYtNmU3MC00MjZjLWFmZDEtNzFjOGZhNWY0ODkwIiwidWlkIjoiMDB1MWlieDhsaGIzYW12SFIwaDgiLCJzY3AiOlsiYWNjb3VudF9yZWFkIiwiZW1haWwiLCJjYW1wYWlnbl9kYXRhIiwicHJvZmlsZSIsImFkZHJlc3MiLCJjb250YWN0X2RhdGEiLCJvcGVuaWQiXSwic3ViIjoiZ2Vla3NxdWFkIiwicGxhdGZvcm1fdXNlcl9pZCI6ImQzYTA2ZTYyLTJmMTQtNGQ5Ni05NDUzLTI2NTkxYWI1M2YwZCJ9.saJxgUYx1_OKUteH01KV71vzjaxqTKnZ3XfD4QKtsIkjrmcf4tUWEFSzjuF1kdxLvlMoCyr_MwO81ApwYX2UU0YRhkVsfw2VLR4KpO89ILul7ZJZyzzsVKak8BrgLhqR1AB7X116VRjsH74vD4D-1e4uKKUlK4yefsZE14kFgDZNi74_WPn5FBGeicwMsStdG3qms8X-6LqIxuZ5fXgSxK9wDEBe-xJfJSqAqo1vJKMqw2JT_NvBBLDXqoSg0_q_0IqbxXEMHdX2J_DHGKrY7w1QQGmeBU_BIlewQPUxUGX-dbRavxncBpItt1tsRLBIiPbPkQ_zDN8_J9lPIxJksA", "scope": "account_read offline_access", "refresh_token": "HFsqfgtZuGyffnD2qb-AQKWDURWAXM8hlgYIFEwaq4E", "id_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIwMDEyMzQ1ejRXMzhHS3BPMGg3IiwibmFtZSI6IkpvaG4gRG9lIiwiZW1haWwiOiJqZG9lQGFiYy5jb20iLCJ2ZXIiOjEsImlzcyI6Imh0dHBzOi8vaWRlbnRpdHkuY29uc3RhbnRjb250YWN0LmNvbS9vYXV0aDIvYXVzengwNm81alJlZlE4RjQwaDciLCJhdWQiOiJmYThhMDZkYy1iMDAwLTQ3NWMtYWNlZC01NWNlYzVhZWUzMjUiLCJpYXQiOjE2NDQ4NTc4NDcsImV4cCI6MTY0NDg2MTQ0NywianRpIjoiSUQuRFhRQ2pxQmd3M28xMnVHdlN5R2ZpQTJ2QjVFcGNvSktsajBqbFhSc2lqayIsImFtciI6WyJwd2QiXSwiaWRwIjoiMDBvbnBtc2prYmdPc0wydlcwaDciLCJub25jZSI6Ijg2MDgyNTYwMyIsInByZWZlcnJlZF91c2VybmFtZSI6Impkb2UiLCJhdXRoX3RpbWUiOjE2NDQ4NTc4NDQsImF0X2hhc2giOiJuWk5sRjduWGo2bV9UNEFKcXl0c1RRIn0.ToO_Ye1YHRx4hWCMBnrT6yksWvkrpHfGmXcHTh7B75A"}
  • token_type — This value is always set to Bearer.

  • expires_in — The number of seconds remaining until the access_token expires.

  • access_token — The new access_token value used to send requests with the V3 API. Access tokens automatically expire 1440 minutes (86,400 seconds). Making an API call with an expired access token returns a 401 unauthorized status code.

  • scope — The type of data in Constant Contact that the user is granting your application permission to use. The offline_access scope is required to get a refresh token.

  • refresh_token — Each refresh token corresponds to an access token. Use the refresh token to obtain a new access_token when the corresponding access_token expires.

  • id_token — The JWT that includes information about the user such as their name and email address, and if specified, the nonce value you passed in the authorization request. Decode the id_token to verify the nonce value and view user information.

For each new access token that you receive, follow best security practices by validating the signature and claims for the access token by completing the procedures that follow.

Load the JSON web-key Set

Use the method that follows to load the Constant Contact public JSON web-key set used to get the access token.

/** * This method uses the java11 http client to load Constant Contact's public json web key set. * In real use cases, this value should be cached. * @return Constant Contact's public json web key set for the v3 API. */ public String getPublicJsonWebKeySet() throws IOException { HttpClient httpClient = HttpClient.newHttpClient(); HttpRequest request = HttpRequest.newBuilder(URI.create("https://identity.constantcontact.com/oauth2/aus1lm3ry9mF7x2Ja0h8/v1/keys")) .GET() .header("Accept","application/json") .header("Content-Type", "application/x-www-form-urlencoded") .build(); HttpResponse<String> httpResponse = httpClient.send(request, HttpResponse.BodyHandlers.ofString()); return httpResponse.body(); }

Verify the Access Token Claims

Use the method that follows to parse the access token, and then validate the signature and claims of the access token. The code examples in this step use the org.jose4j library.

  1. Use the jwt parameter to pass in the access token.
  2. Use the jsonWebKeySetJson parameter to pass the JSON Web Key Set (JWKS) value (this is the value that was returned in the previous Load the JSON web-key set step).
 /** * This method uses the jose4j library to verify the claims on the JWT. * It throws an exception if it fails to parse the JWT, or the JWT does not include the expected claim. * @param jwt String containing a JSON web token. * @param jsonWebKeySetJson the set of keys available at https://identity.constantcontact.com/oauth2/aus1lm3ry9mF7x2Ja0h8/v1/keys * @throws JoseException * @throws InvalidJwtException */ public void verifyJwtToken(String jwt, String jsonWebKeySetJson) throws JoseException, InvalidJwtException { JsonWebKeySet jsonWebKeySet = new JsonWebKeySet(jsonWebKeySetJson); VerificationJwkSelector jwkSelector = new VerificationJwkSelector(); JsonWebSignature jws = new JsonWebSignature(); jws.setCompactSerialization(jwt); JsonWebKey jwk = jwkSelector.select(jws, jsonWebKeySet.getJsonWebKeys()); JwtConsumer jwtConsumer = new JwtConsumerBuilder() .setRequireExpirationTime() .setRequireSubject() .setExpectedIssuer("https://identity.constantcontact.com/oauth2/aus1lm3ry9mF7x2Ja0h8") .setExpectedAudience("https://api.cc.email/v3") .setVerificationKey(jwk.getKey()) .setJwsAlgorithmConstraints(AlgorithmConstraints.ConstraintType.PERMIT, AlgorithmIdentifiers.RSA_USING_SHA256) .build(); jwtConsumer.processToClaims(jwt); }

If the access token is not valid or if a required claim is missing or incorrect, an exception occurs.

Check the following claims:

  • Compare the cid (client identifier) value to ensure that it matches your application API key
  • The platform_user_id claim in the access token uniquely identifies a Constant Contact user.

To check the claims, use the previous code example, except replace jwtConsumer.processToClaims(jwt); with the following:

JwtClaims claims = consumer.processToClaims(token);String cid = claims.get("cid") if (! apiKey.equals(cid)) { throw new InvalidJwtException("Api key in token incorrect");}String userId = claims.get("platform_user_id") if (userId == null) { throw new InvalidJwtException("Token is missing platform_user_id");} 

After verifying the access token claims and signature, use the access token to send requests in the V3 API by adding it to the Authorization request header in the format Authorization: Bearer {your_access_token}.

If the access token expires, users must reauthenticate and reauthorize your application through Constant Contact. Making an API call with an expired access token returns a 401 unauthorized status code.

See the Errors table in the Authorization Overview for information on how to handle authorization request errors.

You can quickly check to see if the access token is expired using the method that follows.

Use the jwt parameter to pass in the access token. This method returns True for an expired token if the expiration time is within 5 minutes (300 seconds) of the current time, or False if the token has not expired. If the access token expires, you can exchange it for a new access and refresh token using the Refresh the Access Token procedure.

 /** * This method checks if the current time is greater than or equal to the JWT expiration claim. * @param jwt A String JSON web token. * @return True if the jwt token is expired. False if the token is not expired. */ public boolean checkIfTokenIsExpired(String jwt) throws InvalidJwtException, MalformedClaimException { JwtConsumer jwtConsumer = new JwtConsumerBuilder() .setRequireExpirationTime() .setSkipDefaultAudienceValidation() .setDisableRequireSignature() .setSkipSignatureVerification() .build(); JwtClaims jwtClaims = jwtConsumer.processToClaims(jwt); return NumericDate.now().getValue() >= jwtClaims.getExpirationTime().getValue(); }

To avoid having to prompt a user to re-authenticate with Constant Contact due to an expired access token, use the refresh token to get a new access token and a new refresh token. To refresh the access token, send a POST request to the https://authz.constantcontact.com/oauth2/default/v1/token authorization endpoint.

Constant Contact rate limits the Token endpoint. A 429 response will likely be returned if you attempt to refresh an access token before every V3 API request. Constant Contact recommends that you only send a refresh token request to get a new access token if your existing access token is expired or about to expire.

Request parameters

  • refresh_tokenRequired. The refresh token corresponds to the access token you are trying to refresh.

  • grant_typeRequired. The value is refresh_token. This specifies that the purpose of this request is to refresh an access token.

Header Formats

In the header, specify the preferred response formats to return as follows:

  • "Accept", "application/json"

  • "Content-Type", "application/x-www-form-urlencoded"

Authentication

This request requires basic authentication. Base64 encode the string client_id:client_secret and provide it in the Authorization header of the request.

Example Request

PHP JAVA cURL

curl -X POST -i -H "Content-Type: application/x-www-form-urlencoded" -H "Authorization: Basic {base64 client_id:client_secret}" "https://authz.constantcontact.com/oauth2/default/v1/token?refresh_token={refresh_token}&grant_type=refresh_token"
/* * This function can be used to exchange a refresh token for a new access token and refresh token. * Make this call by passing in the refresh token returned with the access token. * The response will contain a new 'access_token' and 'refresh_token' *//** * @param $refreshToken - The refresh token provided with the previous access token * @param $clientId - API Key * @param $clientSecret - API Secret * @return string - JSON String of results */function refreshToken($refreshToken, $clientId, $clientSecret) { // Use cURL to get a new access token and refresh token $ch = curl_init(); // Define base URL $base = 'https://authz.constantcontact.com/oauth2/default/v1/token'; // Create full request URL $url = $base . '?refresh_token=' . $refreshToken . '&grant_type=refresh_token'; curl_setopt($ch, CURLOPT_URL, $url); // Set authorization header // Make string of "API_KEY:SECRET" $auth = $clientId . ':' . $clientSecret; // Base64 encode it $credentials = base64_encode($auth); // Create and set the Authorization header to use the encoded credentials, and set the Content-Type header $authorization = 'Authorization: Basic ' . $credentials; curl_setopt($ch, CURLOPT_HTTPHEADER, array($authorization, 'Content-Type: application/x-www-form-urlencoded')); // Set method and to expect response curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // Make the call $result = curl_exec($ch); curl_close($ch); return $result;}
/* * This method is used to exchange a refresh token for a new access token and refresh token. * Make this call by passing in the refresh token returned with the access token. * The response will contain a new 'access_token' and 'refresh_token'. *//** * @param clientId - API Key * @param clientSecret - API Secret * @param refresh_token - Refresh Token * @return - JSON string containing a new access_token and refresh_token * @throws InterruptedException * @throws IOException * @throws URISyntaxException */public static String refreshToken(String clientId, String clientSecret, String refresh_token) throws IOException, InterruptedException, URISyntaxException { // Make authorization header with API Key:API Secret and Base64 encode String credentials = clientId + ":" + clientSecret; String authHeader = "Basic " + Base64.getEncoder().encodeToString(credentials.getBytes()); // Create request URL StringBuilder requestBuilder = new StringBuilder() .append("https://authz.constantcontact.com/oauth2/default/v1/token") .append("?refresh_token=") .append(refresh_token) .append("&grant_type=refresh_token"); URI requestUri = new URI(requestBuilder.toString()); HttpClient httpClient = HttpClient.newHttpClient(); HttpRequest request = HttpRequest.newBuilder(requestUri) .POST(HttpRequest.BodyPublishers.ofString("")) .header("Accept","application/json") .header("Content-Type", "application/x-www-form-urlencoded") .header("Authorization", authHeader) .build(); HttpResponse<String> httpResponse = httpClient.send(request, HttpResponse.BodyHandlers.ofString()); return httpResponse.body();}

Example Response

{ "token_type": "Bearer", "expires_in": "28800", "access_token": "eyJraWQiOiIzSDdLVVpkSDlyNTh6RVVDSzNYMlR1b2o0SjV0eldWUF9FRUxQTDd6X3hjIiwiYWxnIjoiUlMyNTYifQ.eyJ2ZXIiOjEsImp0aSI6IkFULkZ6YUUtTVFFb2dKQ1VzZlhSUGtBZldobDllckJndVlYRWphOGFXd1RyRzgiLCJpc3MiOiJodHRwczovL2lkZW50aXR5LmNvbnN0YW50Y29udGFjdC5jb20vb2F1dGgyL2F1czFsbTNyeTltRjd4MkphMGg4IiwiYXVkIjoiaHR0cHM6Ly9hcGkuY2MuZW1haWwvdjMiLCJpYXQiOjE2NDQ0Mjc3NzMsImV4cCI6MTY0NDQ1NjU3MywiY2lkIjoiY2M5NGMyZDYtNmU3MC00MjZjLWFmZDEtNzFjOGZhNWY0ODkwIiwidWlkIjoiMDB1MWlieDhsaGIzYW12SFIwaDgiLCJzY3AiOlsiYWNjb3VudF9yZWFkIiwiZW1haWwiLCJjYW1wYWlnbl9kYXRhIiwicHJvZmlsZSIsImFkZHJlc3MiLCJjb250YWN0X2RhdGEiLCJvcGVuaWQiXSwic3ViIjoiZ2Vla3NxdWFkIiwicGxhdGZvcm1fdXNlcl9pZCI6ImQzYTA2ZTYyLTJmMTQtNGQ5Ni05NDUzLTI2NTkxYWI1M2YwZCJ9.saJxgUYx1_OKUteH01KV71vzjaxqTKnZ3XfD4QKtsIkjrmcf4tUWEFSzjuF1kdxLvlMoCyr_MwO81ApwYX2UU0YRhkVsfw2VLR4KpO89ILul7ZJZyzzsVKak8BrgLhqR1AB7X116VRjsH74vD4D-1e4uKKUlK4yefsZE14kFgDZNi74_WPn5FBGeicwMsStdG3qms8X-6LqIxuZ5fXgSxK9wDEBe-xJfJSqAqo1vJKMqw2JT_NvBBLDXqoSg0_q_0IqbxXEMHdX2J_DHGKrY7w1QQGmeBU_BIlewQPUxUGX-dbRavxncBpItt1tsRLBIiPbPkQ_zDN8_J9lPIxJksA", "scope": "account_read offline_access", "refresh_token": "s8Mu4hfiwmug7ru4Rcoo4hjkawiw4OUTH2ixvsy3b8"}
  • token_type — The value is always set to Bearer.

  • expires_in - The access_token expiration timestamp, in seconds.

  • access_token — The response body returns a new access_token value.

  • refresh_token — The response body returns a new refresh_token value.

Tags: OAuth2 Authorization Authentication PKCE_Flow Implicit_Flow Authorization_Code_Flow scopes

OAuth2 Authorization Code Flow | Constant Contact Developer Portal (2024)

FAQs

How to get authorization code for OAuth2? ›

OAuth2 Authorization Code Flow
  1. Step 1: Create an Authorization Request.
  2. Example Authorization Request.
  3. Step 2: Get Authorization.
  4. Step 3: Get the Authorization Code.
  5. Step 4: Get the Access Token and Refresh Token.
  6. Step 5: Validate the Access Token. ...
  7. Step 6: Add the Access Token to the Authorization Request.

Why is a bad idea to use OAuth 2.0 for authentication? ›

The purpose of OAuth2 Tokens is to authorize requests at a first-party server (or API). If the third party uses the OAuth2 Access Token as proof of authentication, an attacker could easily impersonate a legitimate user.

What is the difference between implicit and code flow in OAuth 2.0 authorization? ›

With the "Implicit" flow the client (likely a browser) will get a access token, after the Resource Owner (i.e. the user) gave access. With the "Authorization Code" flow however, the client (usually a web server) will only get an authorization code after the Resource Owner (i.e. the user) gave access.

What is an example of OAuth 2.0 flow? ›

OAuth 2.0 allows users to share specific data with an application while keeping their usernames, passwords, and other information private. For example, an application can use OAuth 2.0 to obtain permission from users to store files in their Google Drives. This OAuth 2.0 flow is called the implicit grant flow.

What is the authorization code flow? ›

The OAuth 2.0 authorization code grant type, or auth code flow, enables a client application to obtain authorized access to protected resources like web APIs. The auth code flow requires a user-agent that supports redirection from the authorization server (the Microsoft identity platform) back to your application.

How do I get an auth code? ›

An Auth-Code is required for a domain holder to transfer a domain name from one registrar to another. Registrars provide the Auth-Code to the domain name holder in one of two ways: Allow the registrant to create its own Auth-Codes through a control panel, or. Provide the Auth-Code within five calendar days of a request ...

Is OAuth2 obsolete? ›

It states that OAuth 2.0 is deprecated.

Which API uses OAuth 2.0 for authorization? ›

Google APIs use the OAuth 2.0 protocol for authentication and authorization. Google supports common OAuth 2.0 scenarios such as those for web server, client-side, installed, and limited-input device applications. To begin, obtain OAuth 2.0 client credentials from the Google API Console.

Is OAuth2 authentication or authorization? ›

Principles of OAuth2.0

OAuth 2.0 is an authorization protocol and NOT an authentication protocol. As such, it is designed primarily as a means of granting access to a set of resources, for example, remote APIs or user data. OAuth 2.0 uses Access Tokens.

Why is implicit flow not secure? ›

One reason the implicit flow is less secure than the authorization code flow is the lack of client authentication.

Why do we need an authorization code? ›

Authorization codes have also become commonly used in professional workplaces to maintain information security. Access to servers or VPNs can be managed using authorization codes that are tied to unique user IDs, in order to control who is granted to access sensitive databases.

What is a real life example of OAuth2? ›

A real life example

Here the Authorization Grant flow is now transferring you on the Twitter website where you are asked to enter username and password. You don't have to share your Twitter username and password with LinkedIn. You are just authorizing LinkedIn to do some stuff for you.

How to choose OAuth2 flow? ›

There are a bunch of different OAuth flows which all have specific uses for different needs and cases. Picking the right OAuth flow will depend on the app and the specific scenarios and requirements, like the level of trust between the resource owner and client application, and desired user experience.

What is the difference between authorization code flow and client credentials flow? ›

The main difference between the Client Credentials flow and the Authorization Code flow is that the Client Credentials flow relies on application authorization rather than involving the user. Since there is no user authorization, the flow only interacts with the token endpoint.

How to get transaction authorization code? ›

An authorization code is a six digit alphanumeric code which is generated after making a transaction. You need to contact your Bank / Card provider for helping you with the Authorization Code specific to the transaction date and amount.

How do I find my OAuth 2.0 client ID? ›

Request an OAuth 2. 0 client ID in the Google API Console
  1. Go to the Google API Console.
  2. Select a project, or create a new one. ...
  3. Click Continue to enable the Fitness API.
  4. Click Go to credentials.
  5. Click New credentials, then select OAuth Client ID.
  6. Under Application type select Android.

How to check authorization code? ›

Finding the Authorization Code

To find the authorization code, sign into the Merchant Interface and select "Search for a Transaction" in the Search section. Enter the search criteria to find the transaction you need and select "Search". Then, click on the Transaction ID to view the transaction details page.

How to get OAuth2 access token? ›

  1. Obtain OAuth 2.0 credentials from the Google API Console.
  2. Obtain an access token from the Google Authorization Server.
  3. Examine scopes of access granted by the user.
  4. Send the access token to an API.
  5. Refresh the access token, if necessary.
Jul 16, 2024

Top Articles
Understanding ESG: Governance Factors - M&H Engineering & Consulting for The Oil & Gas Industry
Standard Chartered raises year-end target of Bitcoin to $1,50,000 | Stock Market News
Katie Pavlich Bikini Photos
Gamevault Agent
Hocus Pocus Showtimes Near Harkins Theatres Yuma Palms 14
Free Atm For Emerald Card Near Me
Craigslist Mexico Cancun
Hendersonville (Tennessee) – Travel guide at Wikivoyage
Doby's Funeral Home Obituaries
Vardis Olive Garden (Georgioupolis, Kreta) ✈️ inkl. Flug buchen
Select Truck Greensboro
How To Cut Eelgrass Grounded
Craigslist In Flagstaff
Shasta County Most Wanted 2022
Energy Healing Conference Utah
Testberichte zu E-Bikes & Fahrrädern von PROPHETE.
Aaa Saugus Ma Appointment
Geometry Review Quiz 5 Answer Key
Walgreens Alma School And Dynamite
Bible Gateway passage: Revelation 3 - New Living Translation
Yisd Home Access Center
Home
Shadbase Get Out Of Jail
Gina Wilson Angle Addition Postulate
Celina Powell Lil Meech Video: A Controversial Encounter Shakes Social Media - Video Reddit Trend
Walmart Pharmacy Near Me Open
Dmv In Anoka
A Christmas Horse - Alison Senxation
Ou Football Brainiacs
Access a Shared Resource | Computing for Arts + Sciences
Pixel Combat Unblocked
Umn Biology
Cvs Sport Physicals
Mercedes W204 Belt Diagram
Rogold Extension
'Conan Exiles' 3.0 Guide: How To Unlock Spells And Sorcery
Colin Donnell Lpsg
Teenbeautyfitness
Weekly Math Review Q4 3
Facebook Marketplace Marrero La
Nobodyhome.tv Reddit
Topos De Bolos Engraçados
Gregory (Five Nights at Freddy's)
Grand Valley State University Library Hours
Holzer Athena Portal
Hampton In And Suites Near Me
Stoughton Commuter Rail Schedule
Bedbathandbeyond Flemington Nj
Free Carnival-themed Google Slides & PowerPoint templates
Otter Bustr
San Pedro Sula To Miami Google Flights
Selly Medaline
Latest Posts
Article information

Author: Maia Crooks Jr

Last Updated:

Views: 6036

Rating: 4.2 / 5 (43 voted)

Reviews: 90% of readers found this page helpful

Author information

Name: Maia Crooks Jr

Birthday: 1997-09-21

Address: 93119 Joseph Street, Peggyfurt, NC 11582

Phone: +2983088926881

Job: Principal Design Liaison

Hobby: Web surfing, Skiing, role-playing games, Sketching, Polo, Sewing, Genealogy

Introduction: My name is Maia Crooks Jr, I am a homely, joyous, shiny, successful, hilarious, thoughtful, joyous person who loves writing and wants to share my knowledge and understanding with you.