We're getting the following error when attempting to get an authentication code when the user is not already logged into Pinterest:
{"status": "failure", "message": "Authentication failed.", "code": 2, "data": null}
Example of url we are using to authenticate:
https://api.pinterest.com/oauth/?client_id=1234567891011121314&redirect_uri=https://www.foobar.com/app/influencers/channels/callback/pinterest&scope=read_relationships,read_public&response_type=code&state=cc0c4fbbf2c5058df1932cb561e4494baaef595a
This URL works fine if the user is already logged into Pinterest, it displays the app confirmation and returns a code as expected. However it responds with an error if the user isn't logged in.
The documentation we are following is here:
https://developers.pinterest.com/docs/api/overview/?
This repository has code that is intended to provide a quick start for working with the Pinterest API v5, and also supports Pinterest API v3 plus Pinterest Marketing API v4. Note that all newly-created apps should use Pinterest API v5 and (when necessary) Pinterest Marketing API v4.
One bash script for each version of the Pinterest API provide complete examples: bash/scripts/v3/get_access_token.sh and bash/scripts/v5/get_access_token.sh. In python, the version-independent code in python/src/user_auth.py opens a browser and handles the redirect to obtain an authorization code.
If you enable two-factor authentication, you'll have to enter both your password and a verification code every time you log in to Pinterest. Once set up, you'll receive an email to confirm that two-factor authentication is active on your Pinterest account. You can link a phone number to one account.
Note that all newly-created apps should use Pinterest API v5 and (when necessary) Pinterest Marketing API v4. There is currently python code that implements a number of use cases, JavaScript (nodejs) code with essentially the same functionality, and a bash script that demonstrates the OAuth authentication and authorization flow.
I was experiencing this issue with a few accounts on my app. Turns out they had an old set of permissions associated with their account that needed to be flushed. I did the following:
Hopefully, this is similar to your situation and can resolve it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With