# User (patron) getting authorization error message

**URL:** <https://meta.discourse.org/t/user-patron-getting-authorization-error-message/99578>\
**Category:** Product Support\
**Tags:** patreon\
**Created:** [15 oktober 2018 om 21:02 UTC](https://meta.discourse.org/t/user-patron-getting-authorization-error-message/99578 "2018-10-15T21:02:09Z")\
**Posts on this page:** 1\
**Showing post:** 13

<div class="post-metadata">

**Author:** ![vinothkannans](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vinothkannans/32/86465_2.png) [@vinothkannans](https://meta.discourse.org/u/vinothkannans)\
**Post date:** [17 oktober 2018 om 11:54 UTC](https://meta.discourse.org/t/user-patron-getting-authorization-error-message/99578/13 "2018-10-17T11:54:28Z")

</div>

I think this is not Patreon specific error. I’m able to see few discussions over it in the `omniauth-oauth2` repo. I will check the issue.

> <https://github.com/omniauth/omniauth-oauth2/issues/32>
>
> I'm seeing an error:
> 
> \`Authentication failure! invalid\_credentials: OmniAuth::St…rategies::OAuth2::CallbackError, OmniAuth::Strategies::OAuth2::CallbackError\`
> 
> I am 100% certain my login credentials are correct. I am authenticating via LDAP with devise, that works. The app redirects to the app the user should access and then it raises the OAuth2::CallbackError.
> 
> I subclassed the OAuth2 Strategy to make my own. Located below is my OAuth2 Strategy:
> 
> \`\`\`
> 
> require 'omniauth-oauth2'
> module OmniAuth
> module Strategies
> class Agencyea \< OmniAuth::Strategies::OAuth2
> 
> option :name, "agencyea"
> 
> CUSTOM\_PROVIDER\_URL = 'http://launchpad.lvh.me:3000'
> 
> option :client\_options, {
> :site =\> CUSTOM\_PROVIDER\_URL,
> :authorize\_url =\> "#{CUSTOM\_PROVIDER\_URL}/auth/agencyea/authorize",
> :access\_token\_url =\> "#{CUSTOM\_PROVIDER\_URL}/auth/agencyea/access\_token"
> }
> 
> uid { raw\_info\['id'\] }
> 
> info do
> {
> :email =\> raw\_info\['email'\]
> }
> end
> 
> extra do
> {
> :first\_name =\> raw\_info\['extra'\]\['first\_name'\],
> :last\_name =\> raw\_info\['extra'\]\['last\_name'\]
> }
> end
> 
> def raw\_info
> @raw\_info ||= access\_token.get("/auth/agencyea/user.json?oauth\_token=#{access\_token.token}").parsed
> end
> end
> end
> end
> \`\`\`
> 
> Any thoughts? What other information would you need to help?

> <https://github.com/omniauth/omniauth-oauth2/issues/58>
>
> Even when creating the state myself it got the same error.
> 
> \`\`\` ruby
> session\['om…niauth.state'\] = SecureRandom.hex(24)
> redirect\_to "/auth/google\_oauth2?state=#{session\['omniauth.state'\]}"
> \`\`\`
> 
> Even though the returned state is the same, meaning it should match !
> 
> Isn't there a double redirect or something ? 
> Because if so the : 
> 
> \`\`\` 'ruby
> request.params\['state'\] != session.delete('omniauth.state')
> \`\`\`
> 
> in https://github.com/intridea/omniauth-oauth2/blob/master/lib/omniauth/strategies/oauth2.rb#L72 would explain the problem.
> =\> First passes, second fail.
> 
> https://stackoverflow.com/questions/22386149/why-am-i-getting-csrf-detected-with-omniauth-and-google/23739564#23739564

---

_[View the full topic](https://meta.discourse.org/t/user-patron-getting-authorization-error-message/99578)._
