nickalcala / node-express-oauth2-server-example

Express JS OAuth 2 Server using oauth2-server package
https://niceprogrammer.com/express-js-oauth-2-server-using-oauth2-server-package/
11 stars 8 forks source link

Unable to get access token #9

Open shubhddn01 opened 2 years ago

shubhddn01 commented 2 years ago

Hi, I was going through the blog and this repo. Here I was easily able to register my app and able to login after making few changes. On login, I got the code and state but on the next step I wasn't able to get the access_token. Below are the details :

API  : Get Access Token
Endpoint: http://locahost:3000 /oauth/access_token
Type: POST
Request Params : 
{
"code":"a3310d3a1421f1dd6d533146c235c8397c940fa3",
"client_id":"api"
}

Response Error : 

ERROR :
{
    "error": "invalid_client",
    "error_description": "Invalid client: cannot retrieve client credentials"
}

Please let me know how I can solve this issue. Thanks in advance!

Cha-Shao commented 1 year ago

x-www-form-urlencoded Request:

{
  "client_id": "(The client id when you register an account)",
  "client_secret": "(The client secret when you register an account)",
  "grant_type": "authorization_code",
  "code": "(The code)"
}