I cannot seem to get a refresh token in my call to the /oauth/token endpoint. First I authorize myself like so:
const redirectUrl = chrome.identity.getRedirectURL('auth0');
const clientId = "CLIENT_ID";
const options = {
client_id: clientId,
redirect_uri: redirectUrl,
response_type: 'code',
scope: "offline_access",
audience: "API_IDENTIFIER",
};
const qs = parse.qs;
const domain = "DOMAIN";
const url = `https://${domain}/authorize?${qs.stringify(options)}`;
const resultUrl: string = await new Promise((resolve, reject) => {
chrome.identity.launchWebAuthFlow({
url: url,
interactive: true
}, (callbackURL) => {
resolve(callbackURL);
})
});
This seems to work fine, I then perform the following based on the response I get from the URL:
const response = parse(resultUrl, true).query;
const code = response.code;
const body = JSON.stringify({
redirect_uri: redirectUrl,
grant_type: 'authorization_code',
client_id: clientId,
client_secret: "CLIENT_SECRET",
code,
scope: "offline_access",
});
const result = await fetch(`https://${domain}/oauth/token`, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body
});
After this the response JSON I get contains “access_token”, “scope”, “expires_in”, “token_type”. There is no “refresh_token” as described in this documentation: Get Refresh Tokens
I should also note that the “audience” I use in the authorize call is the right API identifier, and this API has “Allow Offline Access” set to “Enabled”.
So I’m at a bit of a loss, does anyone know what I need to do to get these refresh tokens working?