redirect_mismatch

I sometimes get this error, but only sometimes after clicking connect.

?error=redirect_mismatch&error_description=Parameter+redirect_uri+does+not+match+registered+URI

Why? I don’t see how to fix this and it stops people authenticating with my app.

People auth from my root level domain and return to root level.

it seems that

www.mydomain.com
is not the same as
mydomain.com

But it should be?

I have tried to add a .htaccess maybe this helps others too…

Added this to a .htaccess file in my root

RewriteEngine On
RewriteCond %{HTTP_HOST} ^example.com [nocase]
RewriteRule ^(.*) http://www.example.com/$1 [last,redirect=301]

The URI you set when you created the application in your Twitch account settings and the one pass to “kraken/oauth2/authorize” must be exactly the same for this error will occur.

The subdomain (with or without www) that you are hosting your website on does not matter as long you match your app settings to the authorize call.

I’m using the JS SDK so I don’t pass it manually, sometimes it seemed to fail.

'm not sure if the gt access has solved the issues but it hasn’t happened again.

You should explicitly/manually set the Redirect URI in the Twitch.init call:

<script src="https://ttv-api.s3.amazonaws.com/twitch.min.js"></script>

<script>
  Twitch.init({
      clientId: 'YOUR_CLIENT_ID_HERE',
      redirect_uri: 'http://www.mydomain.com'
  }, function(error, status) {
    // the sdk is now loaded
  });
</script>

Of course be way about if your Twitch Application has a / on the end of the callback URL or not and update redirect_uri accordingly (for a while I was stumped as safari was being an ass and autocompleting the field with a / on the end)

Oh so it seems I do pass it manually then :slight_smile:

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.