How to obtain Pinterest V3 API-KEY or access_token
Asked Answered
B

3

9

I am trying to fetch Pinterest data, which would be the public info of the user(follower count etc), and all pins for a user.

I know the v3 API are up now and v2 apis have been taken down.

I found this link which gives me end points for exactly what I want:

http://techslides.com/most-repinned-pinterest-pins-by-website/

But I am unable to get an access_token. I have asked pinterest for api access but they have not replied. And I am unable to sniff app data too.

I also tried Pinterest's signature tester tool which is on their website but no luck. The link it generates doesn't work either. It returns a authorization failure.

https://developers.pinterest.com/tools/signature/

I have access to APP-ID and Client-Secret. I need to know how can I get an access token/ API-KEY to get the following work fine for me:

https://api.pinterest.com/v3/users/jessicamalba/?access_token=APIKEY

EDIT

Before I am told that is an duplicate of

How to get access token for access Pinterest Api

I would just say that it is not. This question was asked one year ago and was asked in respect to V2 api. Which now return a 404 status. So now here I am asking about the V3 api.

Brillatsavarin answered 12/6, 2014 at 22:29 Comment(0)
A
10

To preface, I saw some discussion that even though you can get the token, it may not work unless you are an approved developer. So you might consider applying to be an API developer while you wait to try to work all this out. Also V3 is beta, so.. This answer might work for now however, it may not work later if it ends up not being the official way to get the token when it comes out of beta.

Step one: Log into pinterest then you need to create an application on the https://developers.pinterest.com/manage/ link which you can also get from the main developers page on pinterest. I chose to create IOS application, even though I don't plan to use this with IOS, just so I could get an application created to try to make the API work.

Part of the creation of the app, asks you to specify a callback url, this is the url on your website that is going to receive the token & token related data in a hash tag {I presume they did this so that only javascript can get at it rather than php directly} however you could modify the hashtag in javascript to drop the hash and redirect it to another url which can collect it as get or post params.

Once created replace the application id "1412345" (i.e. consumer_id, also sometimes called client_id) into the url below.

What I have seen is this number starts with 14...... at present

https://www.pinterest.com/oauth/?consumer_id=1412345&response_type=token

Step two: The executed url above will bring you to a page asking you to authorize the application to access your user account. Once you authorize it it will send the token back to your website. in the hash tag and you can use javascript to read the hashtag

window.location.hash.substr(1, window.location.hash.length) will get you the get params string from the hash tag containing access_token, expires_at (duration in seconds which equals 30 days) and token_type which will equal "bearer"

Note the token will be base_64 encoded, I don't know if it's supposed to stay that way to be used but I presume so.

Affectionate answered 10/7, 2014 at 23:16 Comment(2)
I have gone through your process and got the base64 token and decoded it too. Neither seem to work as an API key, however. Did you manage to get this working talking to API endpoints? If so, could you explain the additional step?Scum
Do this api has a search parameter for timestamp or created_date? As I need to find pins by date order in search api. BTW +1 for great ans. :)Incomparable
B
12

Okay, so as of today, following are the parts of the api that are public and used by widgets.

Public parts of API (used by widgets) Retrieving the pins on a particular board:

GET http://widgets.pinterest.com/v3/pidgets/boards/eecolor/test/pins/
GET http://api.pinterest.com/v3/pidgets/boards/eecolor/test/pins/

Retrieving the pins of a particular user:

GET http://widgets.pinterest.com/v3/pidgets/users/eecolor/pins/

Retrieving the information of (a) particular pin(s):

GET http://widgets.pinterest.com/v3/pidgets/pins/info/?pin_ids=521150988102375972
GET http://widgets.pinterest.com/v3/pidgets/pins/info/?pin_ids=521150988102375972,10133167885969245

Count the number of pins:

http://widgets.pinterest.com/v1/urls/count.json?url={urlEncodedLink} http://widgets.pinterest.com/v1/urls/count.json?url=http%3A%2F%2Fwww.flickr.com%2Fphotos%2Fssass%2F3436030086%2F

Note that the link is returned in the other API responses

You can use ?callback=myJsFunction to use JSONP

GET http://widgets.pinterest.com/v3/pidgets/boards/eecolor/test/pins/?callback=myJsFunction

You can use api instead of widgets and also https

GET http://api.pinterest.com/v3/pidgets/boards/eecolor/test/pins/
GET https://api.pinterest.com/v3/pidgets/boards/eecolor/test/pins/

Brillatsavarin answered 19/2, 2015 at 10:24 Comment(3)
Thanks for ur answer but with this end point there are no creation date for pins ?how could i get the date of pins retrieved?Masthead
Retrieving the pins of a particular user: GET widgets.pinterest.com/v3/pidgets/users/eecolor/pins it is giving only 50 recordsDespond
Just had to say this was absolutely helpful and thanks for the share!!Invent
A
10

To preface, I saw some discussion that even though you can get the token, it may not work unless you are an approved developer. So you might consider applying to be an API developer while you wait to try to work all this out. Also V3 is beta, so.. This answer might work for now however, it may not work later if it ends up not being the official way to get the token when it comes out of beta.

Step one: Log into pinterest then you need to create an application on the https://developers.pinterest.com/manage/ link which you can also get from the main developers page on pinterest. I chose to create IOS application, even though I don't plan to use this with IOS, just so I could get an application created to try to make the API work.

Part of the creation of the app, asks you to specify a callback url, this is the url on your website that is going to receive the token & token related data in a hash tag {I presume they did this so that only javascript can get at it rather than php directly} however you could modify the hashtag in javascript to drop the hash and redirect it to another url which can collect it as get or post params.

Once created replace the application id "1412345" (i.e. consumer_id, also sometimes called client_id) into the url below.

What I have seen is this number starts with 14...... at present

https://www.pinterest.com/oauth/?consumer_id=1412345&response_type=token

Step two: The executed url above will bring you to a page asking you to authorize the application to access your user account. Once you authorize it it will send the token back to your website. in the hash tag and you can use javascript to read the hashtag

window.location.hash.substr(1, window.location.hash.length) will get you the get params string from the hash tag containing access_token, expires_at (duration in seconds which equals 30 days) and token_type which will equal "bearer"

Note the token will be base_64 encoded, I don't know if it's supposed to stay that way to be used but I presume so.

Affectionate answered 10/7, 2014 at 23:16 Comment(2)
I have gone through your process and got the base64 token and decoded it too. Neither seem to work as an API key, however. Did you manage to get this working talking to API endpoints? If so, could you explain the additional step?Scum
Do this api has a search parameter for timestamp or created_date? As I need to find pins by date order in search api. BTW +1 for great ans. :)Incomparable
D
1

this is a official Pinterest Documentation every thing you find it here, I did same for my requirement. Access token

how to use it

But it for V1 api

examples:

https://api.pinterest.com/v1/pins/431430839282408407/?access_token=aaa
https://api.pinterest.com/v1/boards/lorihiney/quotes/pins/?access_token=aa&limit=20&fields=id,link,counts
https://api.pinterest.com/v1/boards/mother1086/test-title/pins/?access_token=aaa&limit=2&fields=id,link,counts
Despond answered 3/12, 2015 at 12:5 Comment(2)
While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From ReviewMotivate
i think now it will be right i edit the answer with some exampleDespond

© 2022 - 2024 — McMap. All rights reserved.