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

#6540 Feature: Adds TikTok Provider #6546

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions docs/docs/reference/05-oauth-providers/tiktok.md
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"
})
]
...
```
32 changes: 32 additions & 0 deletions packages/core/src/providers/tiktok.js
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",

Choose a reason for hiding this comment

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

profile(profile) {
return {
id: profile.open_id,
name: profile.display_name,
image: profile.avatar_url
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
image: profile.avatar_url
image: profile.avatar_url,
email: profile.email ?? null

Do you know if e-mail can be returned?

Copy link
Author

Choose a reason for hiding this comment

The 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
}
}