# Problems with my Redirect URI using rails

**URL:** <https://discuss.dev.twitch.com/t/problems-with-my-redirect-uri-using-rails/5594>\
**Category:** API\
**Created:** [April 5, 2016, 4:52am UTC](https://discuss.dev.twitch.com/t/problems-with-my-redirect-uri-using-rails/5594 "2016-04-05T04:52:46Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![brennanholtzclaw](https://avatars.discourse-cdn.com/v4/letter/b/e47774/32.png) [@brennanholtzclaw](https://discuss.dev.twitch.com/u/brennanholtzclaw)\
**Post date:** [April 5, 2016, 4:52am UTC](https://discuss.dev.twitch.com/t/problems-with-my-redirect-uri-using-rails/5594/1 "2016-04-05T04:52:47Z")

</div>

Sorry for this being a fairly basic question, but I can’t figure this out for the life of me.

I’m building a simple rails app, trying to use the Twitch OAuth to log in users.  
My routes are simple:  
\> get “/auth/twitch”, as: :twitch\_login

> ```
> get "/auth/twitch/callback", to: "sessions#create"
> 
> ```

So, hypothetically my redirect\_uri should be as simple as:

> [http://localhost:3000/auth/twitch/callback](http://localhost:3000/auth/twitch/callback)

I’ve tried this in all configurations I can think of using localhost, 127.0.0.1, with and without the port…

Each time I end up with this error:

> OAuth2::Error  
> Bad Request: {“error”:“Bad Request”,“status”:400,“message”:“Parameter redirect\_uri does not match registered URI”}

Any idea on what simple thing I’m missing?

---

<div class="post-metadata">

**Author:** ![Streusel](https://avatars.discourse-cdn.com/v4/letter/s/d26b3c/32.png) [@Streusel](https://discuss.dev.twitch.com/u/Streusel)\
**Post date:** [April 5, 2016, 6:54am UTC](https://discuss.dev.twitch.com/t/problems-with-my-redirect-uri-using-rails/5594/2 "2016-04-05T06:54:05Z")

</div>

The redirect URL you provided for your registered app under [https://www.twitch.tv/settings/connections](https://www.twitch.tv/settings/connections) does not match with what you provided as a callback. They have to be 100% identical.

---

<div class="post-metadata">

**Author:** ![brennanholtzclaw](https://avatars.discourse-cdn.com/v4/letter/b/e47774/32.png) [@brennanholtzclaw](https://discuss.dev.twitch.com/u/brennanholtzclaw)\
**Post date:** [April 5, 2016, 3:02pm UTC](https://discuss.dev.twitch.com/t/problems-with-my-redirect-uri-using-rails/5594/3 "2016-04-05T15:02:54Z")

</div>

So, I’m using [http://127.0.0.1:3000/auth/twitch/callback](http://127.0.0.1:3000/auth/twitch/callback) as the address, and I literally copied and pasted “[http://127.0.0.1:3000/auth/twitch/callback](http://127.0.0.1:3000/auth/twitch/callback)” into the redirect field on that form.

---

<div class="post-metadata">

**Author:** ![CallMeStrafe](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/callmestrafe/32/1533_2.png) [@CallMeStrafe](https://discuss.dev.twitch.com/u/CallMeStrafe)\
**Post date:** [April 5, 2016, 3:57pm UTC](https://discuss.dev.twitch.com/t/problems-with-my-redirect-uri-using-rails/5594/4 "2016-04-05T15:57:59Z")

</div>

Try making your request from the page you defined as a registered URI?

---

<div class="post-metadata">

**Author:** ![brennanholtzclaw](https://avatars.discourse-cdn.com/v4/letter/b/e47774/32.png) [@brennanholtzclaw](https://discuss.dev.twitch.com/u/brennanholtzclaw)\
**Post date:** [April 5, 2016, 4:37pm UTC](https://discuss.dev.twitch.com/t/problems-with-my-redirect-uri-using-rails/5594/5 "2016-04-05T16:37:36Z")

</div>

Just tried that - no luck.

I’m using the OAuth-Twitch gem, is that changing the response I get?

---

<div class="post-metadata">

**Author:** ![IllusionaryOne](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/illusionaryone/32/2011_2.png) [@IllusionaryOne](https://discuss.dev.twitch.com/u/IllusionaryOne)\
**Post date:** [April 5, 2016, 7:08pm UTC](https://discuss.dev.twitch.com/t/problems-with-my-redirect-uri-using-rails/5594/6 "2016-04-05T19:08:06Z")

</div>

What is rails passing in as the redirect\_uri to Twitch when it calls the API? Maybe that is getting corrupted or is not what you think it is? Assuming you are still having the redirect error.

---

<div class="post-metadata">

**Author:** ![brennanholtzclaw](https://avatars.discourse-cdn.com/v4/letter/b/e47774/32.png) [@brennanholtzclaw](https://discuss.dev.twitch.com/u/brennanholtzclaw)\
**Post date:** [April 5, 2016, 7:47pm UTC](https://discuss.dev.twitch.com/t/problems-with-my-redirect-uri-using-rails/5594/7 "2016-04-05T19:47:24Z")

</div>

I’m really not sure how to check that…

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [April 5, 2016, 7:48pm UTC](https://discuss.dev.twitch.com/t/problems-with-my-redirect-uri-using-rails/5594/8 "2016-04-05T19:48:46Z")

</div>

Are you sure that when you hit save, chrome/browser didn’t accidentally wack a / on the end as a auto complete measure. I’ve had that happen and it’s caught me out once of twice.

But recheck ALL your settings, to make sure you got all the right keys/clientID etc

A Google for “OAuth-Twitch gem” returns Three results with the same name but different authors. Which are you using?

---

<div class="post-metadata">

**Author:** ![brennanholtzclaw](https://avatars.discourse-cdn.com/v4/letter/b/e47774/32.png) [@brennanholtzclaw](https://discuss.dev.twitch.com/u/brennanholtzclaw)\
**Post date:** [April 5, 2016, 8:33pm UTC](https://discuss.dev.twitch.com/t/problems-with-my-redirect-uri-using-rails/5594/9 "2016-04-05T20:33:05Z")

</div>

So - it appears to work now, and I’m not exactly sure why.  
I think the final fix was specifying this in my gemfile:

> gem ‘omniauth-twitch’, git: ‘git://github.com/WebTheoryLLC/omniauth-twitch.git’

Oddly, that didn’t seem to change anything. I then altered the route slightly and it worked perfectly. I was then able to alter the route BACK to what it was, and it still works.

I think I may not have restarted my server in between those steps, and I’m assuming that specifying the gem was the key here. (I was trying to be diligent about restarting the server whenever I made a change, but I can’t be positive I did right after that step).

Thanks for the help everyone!

---

<div class="post-metadata">

**Author:** ![system](https://d2opxh93rbxzdn.cloudfront.net/original/2X/0/05909729875cce3b53e59d5561c4d23bb14948fc.png) [@system](https://discuss.dev.twitch.com/u/system)\
**Post date:** [May 5, 2016, 8:33pm UTC](https://discuss.dev.twitch.com/t/problems-with-my-redirect-uri-using-rails/5594/10 "2016-05-05T20:33:10Z")

</div>

Closed on May 5, 2016, 8:33pm UTC

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