You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a custom provider in next-auth (dingtalk).
The user already is being sent to the authorization URL and can autherize the application there.
Dingtalk then sends the user back to the callback URL (in this case localhost:3000/api/auth/callback/dingtalk?authCode=xxxxxxxxxx) with a authCode in the query.
How can I access this authCode in the query?
{id: 'dingtalk',name: '钉钉',type: 'oauth',clientId: config.oauth.dingtalk.clientId,clientSecret: config.oauth.dingtalk.clientSecret,authorization: {url: 'https://login.dingtalk.com/oauth2/auth',params: {redirect_uri: `${config.http.url}/api/auth/callback/dingtalk`,client_id: config.oauth.dingtalk.clientId,response_type: 'code',scope: 'openid',prompt: 'consent',},},token: {url: 'https://api.dingtalk.com/v1.0/oauth2/userAccessToken',asyncrequest(context){console.log(context)// I thougt that the authCode maybe could be in the context here. Couldnt find it.constrequest=awaitfetch('https://api.dingtalk.com/v1.0/oauth2/userAccessToken',{method: 'POST',headers: {'x-acs-dingtalk-access-token': 'BE3xxxx','Content-Type': 'application/json',},body: JSON.stringify({clientId: context.provider.clientId,clientSecret: context.provider.clientSecret,grantType: 'authorization_code',code: ???// i need to get `authCode` from authorization and use it here}),})constdata=awaitrequest.json()console.log(data)return{tokens: data.accessToken}},},}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I have a custom provider in next-auth (dingtalk).
The user already is being sent to the authorization URL and can autherize the application there.
Dingtalk then sends the user back to the callback URL (in this case
localhost:3000/api/auth/callback/dingtalk?authCode=xxxxxxxxxx
) with a authCode in the query.How can I access this authCode in the query?
Beta Was this translation helpful? Give feedback.
All reactions