Unfortunately every time I try to log in I get the error:
Unauthorized 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.
That is the error the Patreon API returns when the access token provided is invalid. There are 3 reasons you might experience this error in the example project:
You have not correctly set your Creator Access Token in the .env file (key PATREON_ACCESS_TOKEN)
You are not correctly setting the user’s access token when they log in (only applicable if you edited the example)
You have logged into the example using the same account that owns the campaign for which you’ve provided the creator access token, from the README:
Do not log in to your Patreon PHP website with your creator account. You must create a new account for testing. If you log in with your creator account then your Creator’s Access Token will be reset and all requests will fail. When that happens you will need to repeat Step 4 (of Accepting Logins) again. via patreondevelopers.com.
The steps to remedy this are:
Ensure that you have correctly set the creator’s access token in your .env
Ensure that you are using a separate test account to log in to the example application – if not, repeat step 4 from the README
Ensure that, if you’ve modified login.php or patrons.php that you’re correctly setting the accessToken from the Patreon API response
If that doesn’t help, please let me know and I can investigate further for you
Editing to add: you can quickly verify if an Access Token is valid by opening your terminal and running the following command:
curl -X GET https://api.patreon.com/oauth2/api/current_user -H 'Authorization: Bearer access-token'
So to easily determine if your Creator Access Token is valid you can run that command with access-token replaced with the value of PATREON_ACCESS_TOKEN from the .env file, e.g:
curl -X GET https://api.patreon.com/oauth2/api/current_user -H 'Authorization: Bearer zVd2NMt33xi1GtIE_IdzFTyc888usMjwRSinvnWHYGh7'