Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(providers): add WeChat #2519

Closed
wants to merge 2 commits into from
Closed

Conversation

zhuangya
Copy link

@zhuangya zhuangya commented Aug 13, 2021

Reasoning 💡

introduce WeChat OAuth 2.0 provider

Checklist 🧢

  • Documentation
  • Tests
  • Ready to be merged

Affected issues 🎟

@vercel
Copy link

vercel bot commented Aug 13, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/nextauthjs/next-auth/FRNFV5uLmPLU4LmLFddiuvQDVsWh
✅ Preview: https://next-auth-git-fork-zhuangya-wechat-provider-nextauthjs.vercel.app

@vercel vercel bot temporarily deployed to Preview August 13, 2021 10:06 Inactive
@github-actions github-actions bot added core Refers to `@auth/core` providers labels Aug 13, 2021
@zhuangya zhuangya marked this pull request as ready for review August 13, 2021 10:08
@zhuangya zhuangya changed the title WIP: feat(providers): add WeChat feat(providers): add WeChat Aug 13, 2021
@vercel vercel bot temporarily deployed to Preview August 13, 2021 10:14 Inactive
@github-actions github-actions bot added the docs Relates to documentation label Aug 13, 2021
@vercel vercel bot temporarily deployed to Preview August 13, 2021 10:15 Inactive
Copy link
Member

@balazsorban44 balazsorban44 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this PR! We are close to a new major release, so I kindly ask you to change the base of this PR from main to next. Unfortunately, there is a big chance for a few merge conflicts, so the easiest way is to probably to reopen this PR where you base your branch on our next branch to begin with. I am sorry for the inconvenience, this will hopefully not be required for long.

To comply with the new Provider API, I kindly ask you to incorporate my suggestions. I might have a few more when you have a PR against next, but I am happy to help you through this to be merged!

I would also like to ask, do you know how we could set up a test account on WeChat to add it to our basic sign-in test suite to ship this with more confidence?

Feel free to ask me anything

Comment on lines +134 to +136
} else if (provider.id === 'wechat') {
params.appid = provider.clientId || provider.appid
params.secret = provider.clientSecret;
Copy link
Member

@balazsorban44 balazsorban44 Aug 13, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Custom behavior in the core like this won't be supported in the upcoming major release. Read #2411 and the corresponding RFC #1846 for context and to see how you can mitigate this.

Comment on lines +239 to +247
// WeChat has different url params design
if (provider.id === 'wechat') {
const wechatProfileURL = new URL(url)

wechatProfileURL.searchParams.append('access_token', results.accessToken)
wechatProfileURL.searchParams.append('openid', results.openid)

url = wechatProfileURL.href
}
Copy link
Member

@balazsorban44 balazsorban44 Aug 13, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Custom behavior in the core like this won't be supported in the upcoming major release. Read #2411 and the corresponding RFC #1846 for context and to see how you can mitigate this.

Comment on lines +22 to +24
id: profile.openid,
nickname: profile.nickname,
avatar: profile.headimgurl
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The upcoming version will require all built-in providers to return a unified output here by default, which is id, name, email, image, defaulting to null. Read #2411 and the corresponding RFC #1846 for context.

## Documentation

https://developers.weixin.qq.com/doc/offiaccount/en/OA_Web_Apps/Wechat_webpage_authorization.html

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also add a Configuration section

authorizationParams: {
appid: options.clientId
},
protection: "state",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
protection: "state",
protection: ["state"],

@zhuangya zhuangya requested a review from ubbe-xyz as a code owner August 13, 2021 10:41
@vercel vercel bot temporarily deployed to Preview August 13, 2021 10:41 Inactive
@github-actions github-actions bot added the TypeScript Issues relating to TypeScript label Aug 13, 2021
@zhuangya
Copy link
Author

Thank you for this PR! We are close to a new major release, so I kindly ask you to change the base of this PR from main to next. Unfortunately, there is a big chance for a few merge conflicts, so the easiest way is to probably to reopen this PR where you base your branch on our next branch to begin with. I am sorry for the inconvenience, this will hopefully not be required for long.

To comply with the new Provider API, I kindly ask you to incorporate my suggestions. I might have a few more when you have a PR against next, but I am happy to help you through this to be merged!

No worry, I'll take care of this.
I've already gone through your suggestions, and I'd like to read #2411 and #1846 first.

I would also like to ask, do you know how we could set up a test account on WeChat to add it to our basic sign-in test suite to ship this with more confidence?

not yet, but i think i can figure it out

Feel free to ask me anything

Thank you, it's very kind of you!

@stale
Copy link

stale bot commented Oct 12, 2021

Hi there! It looks like this issue hasn't had any activity for a while. It will be closed if no further activity occurs. If you think your issue is still relevant, feel free to comment on it to keep it open. (Read more at #912) Thanks!

@stale stale bot added the stale Did not receive any activity for 60 days label Oct 12, 2021
@stale
Copy link

stale bot commented Oct 19, 2021

Hi there! It looks like this issue hasn't had any activity for a while. To keep things tidy, I am going to close this issue for now. If you think your issue is still relevant, just leave a comment and I will reopen it. (Read more at #912) Thanks!

@stale stale bot closed this Oct 19, 2021
@jonidelv
Copy link

I really need this 😿 is there any chance of this moving forward? Sorry, I'm not yet familiar with the code to help.

@StarDxxx
Copy link

we need wechat

@zhuangya zhuangya deleted the wechat-provider branch October 31, 2022 08:31
@GiantappMan
Copy link

Please support WeChat, WeChat is a commonly used way in China

@kulame
Copy link

kulame commented Dec 31, 2022

we need wechat., please support it !

1 similar comment
@zuohuadong
Copy link

we need wechat., please support it !

@sharkqwy
Copy link

World's 18% users are on WeChat. It doesn't make sense to support all other smaller social providers while ignore it. Please add support for WeChatProvider

@daniel548604106
Copy link

Please support wechat

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Refers to `@auth/core` docs Relates to documentation providers stale Did not receive any activity for 60 days TypeScript Issues relating to TypeScript
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants