SocialiteProviders / Providers

A Collection of Providers for Laravel Socialite
https://socialiteproviders.com
MIT License
504 stars 443 forks source link

Tiktok fails me with the following "code_callengen" #1100

Closed moha-ep closed 1 year ago

moha-ep commented 1 year ago

Hi to everyone ! I have a laravel 10 project and I want to integrate the login with tiktok, I installed the necessary library with the following command : composer require socialiteproviders/tiktok Once installed, I have defined the tiktok service in config/services.php:

'tiktok' => [
        'client_id' => env('TIKTOK_CLIENT_ID'),
        'client_secret' => env('TIKTOK_CLIENT_SECRET'),
        'redirect' => env('TIKTOK_REDIRECT_URI')
    ],

Once I have configured the service credentials, I have added the service provider in app/Providers/EventServiceProvider:

protected $listen = [
        Registered::class => [
            SendEmailVerificationNotification::class,
        ],
        \SocialiteProviders\Manager\SocialiteWasCalled::class => [
            // ... other providers
            \SocialiteProviders\TikTok\TikTokExtendSocialite::class.'@handle',
        ],
    ];

I define the routes for social login

Route::prefix('connect')->group(function(){
    Route::get('/tiktok', function () {
        return Socialite::driver('tiktok')->redirect();
    });
    Route::get('/tiktok/callback', function () {
        return Socialite::callback();
    });

    Route::get('/linkedin', function () {
        return Socialite::driver('linkedin')->scopes(['r_liteprofile', 'r_basicprofile', 'r_organization_social', 'r_organization_admin', 'r_emailaddress'])->redirect();
    });
});

Once everything was installed and configured according to the documentation, I went on to test how it behaves. I'm going to try linkedin first: image

Now it's time to test Tiktok: image And surprise it doesn't work, I have searched in forums, documentation, sub-forums and there is no info about this bug. Has anyone had this problem before?

Development environment information SO: Windows 11 Pro Php: PHP 8.2.8 (cli) (built: Jul 4 2023 15:53:30) (NTS Visual C++ 2019 x64) Laravel Version : 10.28.0
Composer Version:2.5.8
Environment: local
Debug Mode: ENABLED
URL: localhost
Maintenance Mode: OFF

moha-ep commented 1 year ago

I found the bug, it was the redirect url that was misspelled. Before

'tiktok' => [
        'client_id' =>xxx,
        'client_secret' =>yyy,
        'redirect' => http://127.0.0.1
    ],

Now Working:

'tiktok' => [
        'client_id' =>xxx,
        'client_secret' =>yyy,
        'redirect' => https://my-url.com
    ],