How to implement the TikTok Login Kit for Web in PHP

has recently released their new API to allow Social Login via their platform. They called it .

With more Gen-Z and Millennials in the platform, allowing the simplified signup and login process via TikTok is the logical step for many Web Apps, including our very own .

While the implementation is a very basic oauth2 flow, there were no published class nor guides specific to PHP implementation, so I thought useful to publish an and this quick tutorial based on such class.

Step 1: Register your App

First of all, you need to register in the . Process is easy and approval is quite fast; it took us just 24hrs to get approved with .

Pay attention to the approved redirect URLs. While the TikTok page calls them “Redirect Domains”, they actually require full URLs, so the full path of the page where you’re redirected after the TikTok login.

After you register your application you will receive, as usual a Client Key and Client Secret.

Step 2: Install helper class

Use Composer to install the PHP helper

composer require gimucco/tiktok-loginkit

If, for any reason, you’re not using Composer, you can download the class from . Current stable is v0.1.

Step 3: Full Login Example

The login flow is typical:

  • Generate a Redirect Url to send the user to TikTok to authorise your app
  • Receive the Authorisation Token
  • Exchange the Authorisation Token with an Access Token that you can use for the rest of the calls
  • Make a sample call to retrieve the User Information

Here’s a quick code sample

All done! If you have any suggestion on the class or its implementation please feel free to reach out on or .

--

--

Co-founder @Lnk.Bio — Developing stuff on the Web since 2003

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store