-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
#6540 Feature: Adds TikTok Provider #6546
Changes from all commits
771c84b
22c6cc9
f0b5ce0
637b899
b2fabbd
a81d9de
e4e778a
5986624
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
--- | ||
id: tiktok | ||
title: TikTok | ||
--- | ||
|
||
## Documentation | ||
|
||
https://developers.tiktok.com/doc/login-kit-web/ | ||
|
||
## Configuration | ||
|
||
https://developers.tiktok.com/doc/getting-started-create-an-app/ | ||
|
||
## Options | ||
|
||
The **TikTok Provider** comes with a set of default options: | ||
|
||
- [TikTok Provider options](https://github.com/nextauthjs/next-auth/blob/main/packages/next-auth/src/providers/tiktok.js) | ||
|
||
You can override any of the options to suit your own use case. | ||
|
||
:::note | ||
TikTok requires that a `redirect_uri` param is sent. This must be configured to use the full URL, including protocol, domain, port and path to your Sign In API (default path for Auth.js is `api/auth/signin`). It should look something like `https://mydomain.com/api/auth/signin`. | ||
::: | ||
|
||
## Example | ||
|
||
```js | ||
import TikTokProvider from "next-auth/providers/tiktok"; | ||
... | ||
providers: [ | ||
TikTokProvider({ | ||
clientId: process.env.TIKTOK_CLIENT_KEY, | ||
clientSecret: process.env.TIKTOK_CLIENT_SECRET | ||
redirect_uri: "https://mydomain.com/api/auth/signin" | ||
}) | ||
] | ||
... | ||
``` |
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,32 @@ | ||||||||
/** @type {import(".").OAuthProvider} */ | ||||||||
export default function TikTok(options) { | ||||||||
return { | ||||||||
id: "tiktok", | ||||||||
name: "TikTok", | ||||||||
type: "oauth", | ||||||||
version: "2.0", | ||||||||
authorization: { | ||||||||
url: "https://www.tiktok.com/auth/authorize", | ||||||||
params: { | ||||||||
scope: "user.info.basic", | ||||||||
client_key: options.clientId, | ||||||||
}, | ||||||||
}, | ||||||||
token: { | ||||||||
url: "https://open-api.tiktok.com/oauth/access_token", | ||||||||
params: { | ||||||||
client_key: options.clientId, | ||||||||
client_secret: options.clientSecret, | ||||||||
}, | ||||||||
}, | ||||||||
userinfo: "https://open-api.tiktok.com/user/info", | ||||||||
profile(profile) { | ||||||||
return { | ||||||||
id: profile.open_id, | ||||||||
name: profile.display_name, | ||||||||
image: profile.avatar_url | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Do you know if e-mail can be returned? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. https://developers.tiktok.com/doc/tiktok-api-v2-get-user-info/ if you scroll down on this page, there is docs for the User Object - I couldn't find any ref to get an email unfortunately |
||||||||
}; | ||||||||
}, | ||||||||
options | ||||||||
} | ||||||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not already use v2? https://developers.tiktok.com/doc/tiktok-api-v2-get-user-info/