Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

princeoo7's avatar

API authentication via social networks for your Laravel application

Well this title is copied from the medium blog and so if some one as crossed it, please don't complaint ;D

here is the link : https://medium.com/@hivokas/api-authentication-via-social-networks-for-your-laravel-application-d81cfc185e60

I have followed through the blog and the instruction but how should I use it in practical is something is have not able to figured out :(

in the Step 5: Ensure that all works perfectly, there are 3 things I cannot figure out which are as below:

  1. client id ( is it the google client id )
  2. client secret ( is it the google client secret )
  3. access token

error I am facing is :

{
“error”: “invalid_credentials”,
“error_description”: “The user credentials were incorrect.”,
“message”: “The user credentials were incorrect.”
}

has anyone used it ? can someone help me understand how this work ?

thank you for going through my thread / question / post :)

if the image is not available, please visit the article as that article have the same image at the end of article after point 5 as mentioned before.

1-IFr4-VGE-5-BWNr-U3k3gmf-Kw

0 likes
13 replies
tisuchi's avatar

@princeoo7

Here you need to provide the credentials from your social application.

'google' => [
    'client_id' => env('GOOGLE_CLIENT_ID'),
    'client_secret' => env('GOOGLE_CLIENT_SECRET'),
    'redirect' => env('GOOGLE_REDIRECT_URL'),
],

For example, GOOGLE_CLIENT_ID should be replaced by the real google client id.

Make sure you have placed the right id, secret and redirect path.

princeoo7's avatar

I got that part but what is the access_token which needs to be provided for getting the token :/ that's the question on my mind :(

princeoo7's avatar

any update here ? I am just stucked here :(

princeoo7's avatar

@niyo @tisuchi Yes I have created a App on the Sever and if I use the web App method for verification, i.e. the socialite version, it works !

vainway 's avatar

do this

'google' => [ 'client_id' => 'your client id google gave u', 'client_secret' => 'you secrete key google gave u', 'redirect' => 'http://localhost::8000/login/google/callback' ]

in your web.php

Route::get('/login/google', 'Auth\LoginController@redirectToGoogle')->name('gologin'); Route::get('/login/google/callback', 'Auth\LoginController@handleGoogleCallback')->name('gocallback');

princeoo7's avatar

this is the solution for web based implementation for socialite package which is working fine for me.

My main issue is with the api based package coderello / laravel-passport-social-grant.

link: https://github.com/coderello/laravel-passport-social-grant

below is the array which needs to be provided to the oauth/token link:

{
    'grant' => 'social',
    'client_id' => 'laravel Client id',
    'client_scret' => 'laravel Client secret',
    'provider' => 'google',
    'access_token' => 'google token',
}

and here is where I am facing the issue.

bobbybouwmann's avatar

I believe you can leave the access_token empty here. The package will set the token on its own if it needs it for Google. At least that's why I read after looking at the code of the package.

Please or to participate in this conversation.