-
Notifications
You must be signed in to change notification settings - Fork 76
Open
Description
Hi! I've been working on an integration with Asana and realized that there is no internal helper function for Oauth2-based authentication like there was on the first major version of the node client.
When I try to use the Oauth2 endpoints documented here https://developers.asana.com/docs/oauth#pkce-oauth-extension I always get a 400 with no useful error message.
Here's my auth code:
const redirectUri = `${process.env.NEXT_PUBLIC_OAUTH_REDIRECT_URI}/asana`;
const body = {
grant_type: 'authorization_code',
client_id: process.env.ASANA_CLIENT_ID,
client_secret: process.env.ASANA_CLIENT_SECRET,
redirect_uri: redirectUri,
code: req.query.code,
};
const config = {
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
};
const tokenResponse = await axios.post(`https://app.asana.com/-/oauth_token`, body, config);
This is what the response looks like:
{
"message":"Request failed with status code 400",
"name":"AxiosError",
"config":{
"transitional":{
"silentJSONParsing":true,
"forcedJSONParsing":true,
"clarifyTimeoutError":false
},
"transformRequest":[
null
],
"transformResponse":[
null
],
"timeout":0,
"xsrfCookieName":"XSRF-TOKEN",
"xsrfHeaderName":"X-XSRF-TOKEN",
"maxContentLength":-1,
"maxBodyLength":-1,
"env":{
},
"headers":{
"Accept":"application/json, text/plain, */*",
"Content-Type":"application/x-www-form-urlencoded",
"User-Agent":"axios/0.27.2",
"Content-Length":244
},
"method":"post",
"url":"https://app.asana.com/-/oauth_token",
"data":"{\"grant_type\":\"authorization_code\",\"client_id\":\"<REDACTED>\",\"client_secret\":\"<REDACTED>\",\"redirect_uri\":\"<REDCATED>/oauth/asana\",\"code\":\"<REDACTED>\"}"
},
"code":"ERR_BAD_REQUEST",
"status":400
}
Am I missing something obvious here?
Metadata
Metadata
Assignees
Labels
No labels