Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pinterest API - Authorisation Code - Error Code '2'

Tags:

pinterest

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/?

like image 342
Graham House Avatar asked Jul 12 '17 10:07

Graham House


People also ask

What version of Pinterest API do I need to use?

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.

How do I get a Pinterest API Token in Python?

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.

How do I enable two-factor authentication on Pinterest?

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.

What programming language should I use for my Pinterest app?

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.


1 Answers

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:

  1. I went into the "problematic accounts" on Pinterest and went to the settings.
  2. From there, I went to the bottom section where "Apps" are listed and revoked access to my app.
  3. Once I tried to re-auth, everything worked fine from there on.

Hopefully, this is similar to your situation and can resolve it.

like image 130
Dustin G Avatar answered Oct 20 '22 16:10

Dustin G