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.