diff --git a/docs/docs/reference/05-oauth-providers/tiktok.md b/docs/docs/reference/05-oauth-providers/tiktok.md new file mode 100644 index 0000000000..0c12842945 --- /dev/null +++ b/docs/docs/reference/05-oauth-providers/tiktok.md @@ -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" + }) +] +... +``` diff --git a/packages/core/src/providers/tiktok.js b/packages/core/src/providers/tiktok.js new file mode 100644 index 0000000000..21a983e54a --- /dev/null +++ b/packages/core/src/providers/tiktok.js @@ -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 + }; + }, + options + } +}