cannot get access_token from /admin/oauth/access_token

Highlighted
New Member
3 0 0

I am writing a shopify public app using nodeJS. I am totally new to shopify.

The response code of r is 200 but I cannot see any access_token attribute in the response.

I've checked the api_key, api_secret_key and code is correct. Have no idea how to solve it.


Below is my code.

app.get("/connect", (req, res) => {
  let params = {
    client_id: api_key,
    client_secret: api_secret_key,
    code: req.query.code,
  };

  console.log(req.query.shop);

  fetch(`https://${req.query.shop}/admin/oauth/access_token`, {
    headers: {
      "Content-Type": "application/json"
    },
    method: "POST",
    body: JSON.stringify(params),
  }).then((r) => {
    console.log(r);
  });
});

 

 

0 Likes
Highlighted
Shopify Partner
69 12 23

Hi,

Since you are new and to speed up your app building process, I will suggest you to use pre-existing npm packages for OAuth.

https://www.npmjs.com/package/shopify-node-api

OR

https://github.com/lpinca/shopify-token

0 Likes
Highlighted
Excursionist
28 0 3

What happens if you change it to:

 .then((r) => r.json())
.then(result => console.log(result))
0 Likes