nextauthjs / nextauthjs/next-auth
wechat's text/plain response cause oauth4webapi throw error so next-auth wechat login failed
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 28.4k
- Forks
- 4k
- PR merge metrics
- No merged PRs in 30d
Description
Environment
System:
OS: Linux 5.4 Ubuntu 20.04.6 LTS (Focal Fossa)
CPU: (32) x64 AMD Ryzen 9 5950X 16-Core Processor
Memory: 42.71 GB / 50.14 GB
Container: Yes
Shell: 5.0.17 - /bin/bash
Binaries:
Node: 20.9.0 - /usr/bin/node
Yarn: 1.22.21 - /usr/bin/yarn
npm: 10.1.0 - /usr/bin/npm
pnpm: 8.15.1 - /usr/bin/pnpm
bun: 1.1.42 - ~/.bun/bin/bun
Reproduction URL
https://github.com/xiangnanscu/wecha-login
Describe the issue
the error lines in oauth4webapi's processGenericAccessTokenResponse function logic. As the author doesn't want to change it, so would you mind solve this?
@KaygNas
https://github.com/nextauthjs/next-auth/pull/10236
this is related code:
https://github.com/panva/oauth4webapi/pull/155
How to reproduce
the code's like:
import WeChat from '@auth/core/providers/wechat';
import { CommonProviderConfig } from './sso.config';
const provider = {
id: 'wechat',
provider: WeChat({
...CommonProviderConfig,
clientId: process.env.AUTH_WECHAT_ID,
clientSecret: process.env.AUTH_WECHAT_SECRET,
platformType: 'WebsiteApp',
profile: (profile) => {
return {
email: null,
id: profile.unionid,
image: profile.headimgurl,
name: profile.nickname,
providerAccountId: profile.unionid,
};
},
}),
};
export default provider;
Then the end user scan qrcode, approve, and then error happend.
Expected behavior
no error
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the @auth/core/providers/wechat configuration and trace the token exchange into oauth4webapi's processGenericAccessTokenResponse function. Review next-auth pull request 10236 and oauth4webapi pull request 155, then reproduce the WebsiteApp login flow; done means the text/plain response no longer causes an error and WeChat login completes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- nextjs, node.js, typescript
- Domain
- api, authentication
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 32/100