Open joepio opened 3 years ago
Hi @joepio — thanks for raising the issue. Indeed the documentation could be clarified. However, it seems to me that what's amiss here is background about the OAuth authorization code flow, which is not specific to this SDK. Please take a look at https://oauth.net/2/grant-types/authorization-code/ — the resources linked at the bottom of that page, in particular, offer a step-by-step overview of how it works.
As described in those pages, the authorization code needs to be is obtained via a manual process that can't be automated in code — which is a security feature: it ensures the user is shown a permissions screen to agree to, just like when you use your Google credentials to register a new account on a third-party website.
Please check our API documentation which explains how this process works in Uphold (note that it doesn't provide in-depth documentation about how OAuth works in general). You may also find it useful to check our runnable sample code for this flow.
Let me know if that helps!
Thanks for the help, @waldyrious !
I'm a bit confused about using the Authorization flow, as I understood that (as a business API user) I should use the Client-Crendentials flow over the Web Application flow. I've succeeded in getting a token using the Client-Credentials flow, but I don't know how to deal with the Authorization flow.
Can I use the obtained token in the SDK? The .setToken()
method seems to require a refresh_token
, too, which I didn't get using the Client-Credentials flow.
It seems to me that the SDK is primarily designed for the Web Application flow, and not for the Client Credentials flow. Is that correct?
I'm trying to set up an app using the SDK, but I can't get my client to authorise.
Here's the relevant part of the docs that I fail to understand:
My question boils down to this: what do I put in the
code
argument?This is my code:
And the error that I get:
Suggestions
Maybe I'm just missing something trivial, or this step is actually very simple and I'm just lacking some basic knowledge, but otherwise:
Unhandled rejection UnauthorizedError: unauthorized
Authorization code
Versions
Node v15.3.0, SDK 2.4.0