401 Unauthorized Error from OAUTH2 Endpoint

Hello, I’m working to use the Patreon OAUTH2 and APIv2 endpoints to sign in users. I’m very often getting the following error:

The server could not verify that you are authorized to access the URL requested. You either supplied the wrong credentials (e.g. a bad password), or your browser doesn’t understand how to supply the credentials required., id: *****, status: 401, title: Unauthorized.

I’ve made sure to grant the correct scope in the initial token grant (scope - identity[email]) as well.

What’s strange is that this happens intermittently, and sometimes succeeds after waiting 15-20 minutes or so.

Any help is appreciated!

So it happens intermittently - it works for some time and not for some time?

Yeah, I was actually able to figure it out with some help by adding an additional “identity” scope:

Uri.https('www.patreon.com', '/oauth2/authorize', {
              'response_type': 'code',
              // 'client_id':
              'redirect_uri': 'http://localhost:8000/auth.html',
              'scope': 'identity identity[email]',
            });

Before:

Uri.https('www.patreon.com', '/oauth2/authorize', {
              'response_type': 'code',
              // 'client_id':
              'redirect_uri': 'http://localhost:8000/auth.html',
              'scope': 'identity[email]',
            });

Is that expected?

Of course. Without the proper scope you cant get the relevant data. identity and identity[email] are different scopes.

I just had this exact same issue and adding identity to the scope fixes it for all accounts. It is intermittent on which accounts it works for. Definitely seems like a bug on Patreon’s side where just having identity[email] isn’t sufficient

If you are not able to access the user’s email without also being able to access the user’s identity, that’s expected behavior.