klaviyo / klaviyo-api-node

Node sdk for the Klaviyo API
54 stars 17 forks source link

Refresh token does not update access token #84

Open fbahacker21 opened 1 week ago

fbahacker21 commented 1 week ago

I tried to use my existing refresh token to fetch a new access token but it does not return anything new, it returns correctly but the access token and all the response object is the same old one.

const refresh_token = "123"

const response = await fetch(KLAVIYO_TOKEN_URL, {
    method: "POST",
    headers: {
      Authorization: getBasicAuthorizationHeader(),
      "Content-Type": "application/x-www-form-urlencoded",
    },
    body: new URLSearchParams({
      grant_type: "refresh_token",
      refresh_token: refresh_token,
    }),
  })
ben-horgan-klaviyo commented 1 week ago

Thanks for bringing this up- unfortunately I can't reproduce this behavior. Running this block with my real refresh token, I get a different result each time it is run:

fetch(KLAVIYO_TOKEN_URL, {
    method: "POST",
    headers: {
        Authorization: getBasicAuthorizationHeader(),
        "Content-Type": "application/x-www-form-urlencoded",
    },
    body: new URLSearchParams({
        grant_type: "refresh_token",
        refresh_token: refresh_token,
    }),
}).then(r => r.json()).then(r => console.log(r.access_token))

Regardless, this issue is more likely to do with the API rather than the SDK. Please contact support so we can look into this more closely.