Giter Site home page Giter Site logo

Authorization Failed ? about pinsharp HOT 22 CLOSED

GlennIM avatar GlennIM commented on June 16, 2024
Authorization Failed ?

from pinsharp.

Comments (22)

Krusen avatar Krusen commented on June 16, 2024

Does the exception contain any message about what is going wrong? Like "expired access token" or something?

from pinsharp.

GlennIM avatar GlennIM commented on June 16, 2024

When I catch the exception, the message is only "Authorization Failed".

I looked at the app and the status says...

In development
You're almost ready! You still need at least 1 collaborator to authorize your app before you can submit. Also, in order to review your app, we require a fully testable implementation and instructions for how to authenticate with your service.

Does this matter?

Under Plateforms...

Site URL is: https://www.spygearco.net
Redirect URIs is greyed out and says... https://localhost/

from pinsharp.

GlennIM avatar GlennIM commented on June 16, 2024

Also, can you briefly explain how to (or better yet a short screen cast) create a Pinterest App so that your Api can successfully connect to it and use the functions?

I'm assuming you have to create a Pinterest App for every site you want to use your Api with, correct?

Thanks, Glenn

from pinsharp.

Krusen avatar Krusen commented on June 16, 2024

Looks like you are creating the client with your App Secret - you need to get an Access Token.

var authUrl = PinSharpAuthClient.BuildAuthorizationUrl(AppId, RedirectUrl, PinSharp.Api.Scopes.ReadPublic);

Go to that authUrl and approve that the app can access your stuff. It will then redirect you to your RedirectUrl with a query string appended like ?state=xxxxxx&code=89c0dc7470c05faa.

Use the value of the code query string to get an access token:

var code = "89c0dc7470c05faa";
var accessToken = PinSharpAuthClient.GetAccessTokenAsync(AppId, AppSecret, code);

Then create the PinSharpClient using that access token:

var client = new PinSharpClient(accessToken);

from pinsharp.

GlennIM avatar GlennIM commented on June 16, 2024

Thanks... I don't know what you mean by "Go to that authUrl and approve that the app can access your stuff." Can you please explain?

-Glenn

from pinsharp.

Krusen avatar Krusen commented on June 16, 2024

authUrl will look like this:

https://api.pinterest.com/oauth/?response_type=code&client_id=5465468465134153&redirect_uri=https://www.google.dk&scope=read_public&state=a18e845450

Open that in a browser.

from pinsharp.

GlennIM avatar GlennIM commented on June 16, 2024

Forgive me, I'm a total novice at this...

All I have is my Site URL https://www.spygearco.net

What do I use for the client_id and redirect_uri? Is the client_id the same as the App ID ?

from pinsharp.

Krusen avatar Krusen commented on June 16, 2024
var authUrl = PinSharpAuthClient.BuildAuthorizationUrl(AppId, RedirectUrl, PinSharp.Api.Scopes.ReadPublic);

// authUrl will be something like this:
// https://api.pinterest.com/oauth/?response_type=code&client_id=5465468465134153&redirect_uri=https://www.google.dk&scope=read_public&state=a18e845450

Open the return authUrl in your browser (log in to Pinterest if not already logged in) and approve your app.

Your browser will then be redirected to the RedirectUrl you used earlier (the same have configured in your App settings). At the end of the URL will be a query string appended like ?state=xxxxxx&code=89c0dc7470c05faa.

Use the value of the code parameter to get an access token:

var code = "89c0dc7470c05faa";
var accessToken = await PinSharpAuthClient.GetAccessTokenAsync(AppId, AppSecret, code);

Then create the PinSharpClient using that access token:

var client = new PinSharpClient(accessToken);

from pinsharp.

Krusen avatar Krusen commented on June 16, 2024

The redirect URL is configured here in your App settings:

image

You can enter several URLs if you want. I have set mine to https://www.google.dk.

from pinsharp.

GlennIM avatar GlennIM commented on June 16, 2024

I'm getting this compiler error for var client = new PinSharpClient(accessToken);

Argument 1: cannot convert from 'System.Threading.Tasks.Task' to 'string'

Also, how does the Pinterest App created relate to the pinterest account?

from pinsharp.

Krusen avatar Krusen commented on June 16, 2024

Sorry, I forgot an await in there.

var accessToken = await PinSharpAuthClient.GetAccessTokenAsync(AppId, AppSecret, code);

from pinsharp.

Krusen avatar Krusen commented on June 16, 2024

The app doesn't relate to the pinterest account. The access token you get is bound to the account you are logged in with, when you visit the authUrl and approves that the app can access your information.

from pinsharp.

GlennIM avatar GlennIM commented on June 16, 2024

I double checked the code below and put the RedirectURL in the App.

var code = "93bb84390bc55590";
var accessToken = await PinSharpAuthClient.GetAccessTokenAsync("4961064019864599783", "2e12f14e1ff2074c9df2428cabfb5f0cf421a2241855418af915cb1c00c815b5", code);

OK. Now I get this error message...

"Response status code does not indicate success: 401 (Unauthorized)."

  • Please advise

from pinsharp.

GlennIM avatar GlennIM commented on June 16, 2024

Well I got it to work once. Then tried my code again and now get this error message.

"Response status code does not indicate success: 429 (Too Many Requests)."

What does this mean?

Also, do you execute this URL code https://api.pinterest.com/oauth only once to get the code value?

Also, can the same Pinterest App work for multiple Pinterest accounts?

from pinsharp.

GlennIM avatar GlennIM commented on June 16, 2024

I installed this program PostMan and it's a lot easier to create an Access Token to use your API.

Do you recommend using a new Pinterest App for each Pinterest account that is created in order to pin to various boards?

from pinsharp.

Krusen avatar Krusen commented on June 16, 2024

Also, do you execute this URL code api.pinterest.com/oauth only once to get the code value?

When you have the Access Token you can re-use that until it expires. You should an error when it does, then just repeat the steps you did before to get a new Access Token.

Also, can the same Pinterest App work for multiple Pinterest accounts?

Do you recommend using a new Pinterest App for each Pinterest account that is created in order to pin to various boards?

You can use the same App for many users. If you want to test, just log into another account before you visit the authUrl.

You will need to create an Access Token for each user and use that one, when pinning to boards that they own.

from pinsharp.

GlennIM avatar GlennIM commented on June 16, 2024

I need your input. I got your API working on my end and submitted my App to pinterest and they rejected it. What are the proper steps to get the App accepted by pinterest to allow for the maximum rate limit of calls?

from pinsharp.

Krusen avatar Krusen commented on June 16, 2024

image

from pinsharp.

GlennIM avatar GlennIM commented on June 16, 2024

Thanks again,

Would you happen to know of an API for C# that can pin to a pinterest account using just the account eMail, Password and Optional Proxy IP? Using an App and trying to get it approved for maximum pinning seems like a real hassle.

-Glenn

from pinsharp.

Krusen avatar Krusen commented on June 16, 2024

I don't I'm sorry.

from pinsharp.

GlennIM avatar GlennIM commented on June 16, 2024

Hi Again,

Do I need to have my App approved by Pinterest to use your API? What is the advantages of getting the App approved?

from pinsharp.

Krusen avatar Krusen commented on June 16, 2024

Please, read Pinterest's developer documentation or ask them. I'm not in any way affiliated with Pinterest. My library just lets you call their API.

Effective April 16 2018, all unapproved apps are allowed 10 calls per hour for each unique user token.

After you successfully submit an app for approval, each app (with a unique app ID) is allowed 1000 calls per hour for each unique user token.

In both cases, the 60-minute window is a sliding window based on when you make your first request. If you hit your rate limit, you’ll have to wait a minimum of 1 hour to get a few more requests.

from pinsharp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.