1

Hello i am trying to integrate Pinterest via Socialite in my new laravel 11 application.

I have done the following steps as said in the documentation.

Basic Socialite Documentation: https://socialiteproviders.com/usage/#_1-installation

Specific Documentation for Pinterest: https://socialiteproviders.com/Pinterest/

Installed following package: composer require socialiteproviders/pinterest

Package documentation: https://packagist.org/packages/socialiteproviders/pinterest

Register service provider in app\bootstrap\providers.php

<?php

return [
    App\Providers\AppServiceProvider::class,
    \SocialiteProviders\Manager\ServiceProvider::class,
];

Add configuration in app\config\services.php

    'pinterest' => [
        'client_id' => env('PINTEREST_CLIENT_ID'),
        'client_secret' => env('PINTEREST_CLIENT_SECRET'),
        'redirect' => env('PINTEREST_REDIRECT_URI')
    ],

Add Event Listener in app\Providers\AppServiceProvider.php

<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Event;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Register any application services.
     */
    public function register(): void
    {
        //
    }

    /**
     * Bootstrap any application services.
     */
    public function boot(): void
    {
        Event::listen(function (\SocialiteProviders\Manager\SocialiteWasCalled $event) {
            $event->extendSocialite('pinterest', \SocialiteProviders\Pinterest\PinterestExtendSocialite::class);
        });
    }
}

In my controller i now want to call Pinterest via Socialite as following:

public function create()
    {
        $redirectUrl = Socialite::driver('pinterest')
            ->setScopes(['boards:read', 'boards:read_secret', 'boards:write', 'boards:write_secret', 'catalogs:read', 'catalogs:write', 'pins:read',
                'pins:read_secret', 'pins:write', 'pins:write_secret', 'user_accounts:read'])
            ->redirect()
            ->getTargetUrl();
        return response('', 409)->header('X-Inertia-Location', $redirectUrl);
    }

But following error pops up(image):

SocialiteProviders\Pinterest\PinterestExtendSocialite does not extend Laravel\Socialite\Two\AbstractProvider

I already used the same package in a laravel 10 application, it was working there. Would be glad if someone could help me.

0