1- import WeChat from '@auth/core/providers/wechat' ;
1+ import WeChat , { WeChatProfile } from '@auth/core/providers/wechat' ;
22
33import { CommonProviderConfig } from './sso.config' ;
44
@@ -9,7 +9,7 @@ const provider = {
99 clientId : process . env . AUTH_WECHAT_ID ,
1010 clientSecret : process . env . AUTH_WECHAT_SECRET ,
1111 platformType : 'WebsiteApp' ,
12- profile : ( profile ) => {
12+ profile : ( profile : WeChatProfile ) => {
1313 return {
1414 email : null ,
1515 id : profile . unionid ,
@@ -18,6 +18,18 @@ const provider = {
1818 providerAccountId : profile . unionid ,
1919 } ;
2020 } ,
21+ style : { bg : '#fff' , logo : 'https://authjs.dev/img/providers/wechat.svg' , text : '#000' } ,
22+ token : {
23+ async conform ( response : Response ) {
24+ const data = await response . json ( ) ;
25+ console . log ( 'wechat data:' , data ) ;
26+ return new Response ( JSON . stringify ( { ...data , token_type : 'bearer' } ) , {
27+ headers : { 'Content-Type' : 'application/json' } ,
28+ } ) ;
29+ } ,
30+ params : { appid : process . env . AUTH_WECHAT_ID , secret : process . env . AUTH_WECHAT_SECRET } ,
31+ url : 'https://api.weixin.qq.com/sns/oauth2/access_token' ,
32+ } ,
2133 } ) ,
2234} ;
2335
0 commit comments