cancel
Showing results for 
Search instead for 
Did you mean: 

Invalid redirect

Member

Re: Invalid redirect

Hi Dave, 

                Thanks for the response. Looks like, I was able to resolve my issue with adding website to the application. It would really help WEB SITE if you make this a required field. Atleast for future users.

 

invalid redirect was really misdirecting and I wasted almost a day, looking at the gem and some error from my end.

 

It would also help atleast if the error message can give little more detail or some kind of documentation that could say the possible causes of the same error, but different reasons. 

New Member

Re: Invalid redirect

<!DOCTYPE HTML>
<html>
<head>
    <title>Constant Contact API v2 OAuth2 Example</title>
    <link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-combined.min.css" rel="stylesheet">
    <link href="styles.css" rel="stylesheet">
</head>

<!--
README: Get an access token
This example flow illustrates how to get an access token for a Constant Contact account owner using the OAuth2 server flow.
You must have a valid Constant Contact API Key, consumer sercret, and associated redirect_uri. All of these can be obtained from
http://constantcontact.mashery.com.
-->

<?php
// require the autloader
require_once '../src/Ctct/autoload.php';

use Ctct\Auth\CtctOAuth2;
use Ctct\Exceptions\OAuth2Exception;

// Enter your Constant Contact APIKEY, CONSUMER_SECRET, and REDIRECT_URI
define("APIKEY", "[REDACTED]");
define("CONSUMER_SECRET", "[REDACTED]");
define("REDIRECT_URI", "[REDACTED]");

// instantiate the CtctOAuth2 class
$oauth = new CtctOAuth2(APIKEY, CONSUMER_SECRET, REDIRECT_URI);

?>

<body>
<div class="well">
    <h3>OAuth 2 Authorization Example</h3>

    <?php
    // print any error from Constant Contact that occurs during the authorization process
    if (isset($_GET['error'])) {
        echo '<span class="label label-important">OAuth2 Error!</span>';
        echo '<div class="container alert-error"><pre class="failure-pre">';
        echo 'Error: ' . $_GET['error'];
        echo '<br />Description: ' . $_GET['error_description'];
        echo '</pre></div>';
        die();
    }

    // If the 'code' query parameter is present in the uri, the code can exchanged for an access token
    if (isset($_GET['code'])) {
        try {
            $accessToken = $oauth->getAccessToken($_GET['code']);
        } catch (OAuth2Exception $ex) {
            echo '<span class="label label-important">OAuth2 Error!</span>';
            echo '<div class="container alert-error"><pre class="failure-pre">';
            echo 'Error: ' . $ex->getMessage();
            echo '</pre></div>';
            die();
        }

        echo '<span class="label label-success">Access Token Retrieved!</span>';
        echo '<div class="container alert-success"><pre class="success-pre">';
        print_r($accessToken);
        echo '</pre></div>';

    } else {
        ?>
        <!-- If the 'code' query parameter is not present, display the link the user needs to visit to initiate the oauth flow -->
        <button class="btn btn-primary" type="button"
                onclick="window.location.href='<?php echo $oauth->getAuthorizationUrl(); ?>';">Get Access Token
        </button>
    <?php } ?>
</div>

</body>
</html>

 

Please solve this issue

Honored Contributor

Re: Invalid redirect

Hello,

 

You can correct this issue by editing your API key in Mashery so that yhe Redirect URI matches the URI that is used in your code. To edit your key you will need to navigate to https://constantcontact.mashery.com/apps/myapps and log in to your Constant Contact developer account. Once you have updated the key, it may take up to 5 minutes for those changes to be fully propagated to our servers.

 

If you continue to have any issues after updating your Redirect URI, please let me know!

 

Sincerely,

Elijah G.
API Support Engineer
Occasional Visitor

Re: Invalid redirect

Hi,

Is anyone still facing the same "Redirect URI mismatch" issue?

 

I'm trying to use the OmniAuth gem for Rails https://github.com/asanghi/omniauth-constantcontact2 and my application seems to be going to Constant Contact correctly till "Allow Access?"(https://oauth2.constantcontact.com/oauth2/oauth/confirm_access) page  but then it fails  with error message "Redirect URI mismatch" error.

redirect_uri_mismatch: Redirect URI mismatch. {

"error": "redirect_uri_mismatch", "error_description": "Redirect URI mismatch."

}


My callback URI for application is set as http://localhost:3000/auth/constantcontact/callback

Moderator

Re: Invalid redirect

Hello,

 

Looking at that github the redirect URI you are using is listed as the development redirect according to the readme.md file. It is also linking to our older v1 API information. Are you using a v1 API or a v2 API key? Do not post your API key. Did you create your API key using this website? https://constantcontact.mashery.com/

 

If you did then log in and click on My Account in the upper right. Click on Applications, then click on Edit. This will show you what redirect URI you have set up for your API key. It needs to match the redirect that is in your code. You can change either location. If you change the information in the API key location it can take up to 10 minutes to update.

 

If you need to post information that should be kept private I suggest to email us at webservices@constantcontact.com.


Regards,
Jimmy D.
Tier II API Support Engineer
Highlighted
Occasional Visitor

Re: Invalid redirect

Invalid redirect.

Please close the window to return to your application.

Still need help?
You can post a new message in the Community or find us on Twitter Mon-Fri 8am - 8pm ET. We've got real people waiting to help you out. Click below to start a conversation!