Invalid OAuth token error

I tried to test the API, but every time I send an import request, I return an error of 401. I don’t know where it went wrong.

{error: “Unauthorized”, status: 401, message: “Invalid OAuth token”}

baseURL: '',
timeout: 6000,
    'Authorization':'Bearer <access token>'

I got oauth token by referring to this.


Once you get the code from that auth flow, do you follow the the rest of the require steps explained in the documentation to exchange that code for an Access Token?

Yes, I changed the client_id part to my client ID and got an access token. I did it the same way two months ago, but there was no problem then.

Did you exchange the returned ?code for an access token as per step 3?

3) On your server, get an access token by making this request:

    ?client_id=<your client ID>
    &client_secret=<your client secret>
    &code=<authorization code received above>
    &redirect_uri=<your registered redirect URI>
Here is a sample request:


On the docs Dist Linked?

Aha, I haven’t done phase three so far. Thanks to you, you received a refresh token and an access token! But the status is still 401, what should I do to use the API freely?

Whats the body message attached to the 401?

Here’s what the message is about.

    "status": 400,
    "message": "Invalid authorization code"

Is it possible to request a request only once? I sent the request several times because I didn’t know well.

That suggests you tried to reuse the ?code to get an access token.

A ?code can only be exchanged for an access token once.

Fortunately, I sent the request from the beginning and received the token in the form of JSON. By the way, how can I use the API using the token I received now?
The status of 401 is the result of the api requested by axios.get().

Below is the response I received after running step 3.

    "access_token": "access_token",
    "expires_in": 14376,
    "refresh_token": "refresh_token",
    "scope": [
    "token_type": "bearer"

You have already posted the answer:

Step 3 you exchange the ?code for a token.
Then you take the token from the JSON blob and use that in API requests

I put in the access token and it works well. I think I know what the problem was now. I think it was because I didn’t go through the middle stage. Thank you!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.