Search code examples
phplaravelinstagram-api

Laravel. Driver [instagram] not supported. Cannot handle the callback response


I'm working on Instagram API and I want to make auth via Instagram. The first step of it - redirect user to IG page. I'm redirecting

return redirect()->away('https://api.instagram.com/oauth/authorize/?client_id='. $this->client_id .'&redirect_uri='. url('instagram/login/callback') .'&response_type=code');

When I log in I get an error - Driver [instagram] not supported

I already wrote IG API credentials in my services.php, ENV file. I created client in instagram website. But everytime, when user loggin in and redirecting back - he gets this error. I'm googling 2 days. I even used 2-3 packages from github for Instagram, but I'm still getting the same error. I cleared caches with every possible ways - all php artisan clear commands, manually deleting cache from /bootstrap dir.

The FB API works perfect, but not this.

Here is my configs:

.env

INSTAGRAM_ID=54c582bd3ea944b78f741c8aac3001ce
INSTAGRAM_SECRET=4a3***********8c

services.php

'instagram' => [
        'client_id' => env('INSTAGRAM_ID'),
        'client_secret' => env('INSTAGRAM_SECRET'),
        'redirect' => '/instagram/login/callback',
    ],

InstagramController.php

class InstagramController extends Controller
{
    private $client_id;

    private $client_secret;

    public function __construct(Request $request)
    {
        $this->client_id = config('services.instagram.client_id');
        $this->client_secret = config('services.instagram.client_secret');

    }



    /**
     * Show Instagram API submit page
     *
     * @return \Illuminate\View\View
     */
    public function getAPIPage(Request $request){

        return redirect()
            ->away('https://api.instagram.com/oauth/authorize/?
             client_id='. $this->client_id .'&redirect_uri='. 
             url('instagram/login/callback') .'&response_type=code');
         }
}

I'm using Laravel Socialite.

What can I do else?


Solution

  • Solved.

    @sam told me to do all things from instructions. I didn't add the listener events before, but when I added it - API worked. I didn't understand why, but we need to add listener classes in EventServiceProvider.php.

    Do step by step: http://socialiteproviders.github.io/providers/instagram/