Hello Dev
I appreciate your time & intention.
Recently, i am trying to implement social login with laravel API.
I have implemented the Social login for web. And it’s working perfectly.
Facing problem to implement the same feature for React Native application via API.
I have created a public API Route for the social login via API.
Ex: https://example.com/api/social-login/{provider}/callback
Method : POST
Req Body : access_token (This token getting from login via Gmail account at React Native App)
After getting this access token i am passing as Req Body to the API.
Here is Code snippet :
public function handleProviderCallback(Request $request, $provider){
try{
$accessToken = $request->access_token
$socialProvider = $socialProvider = Socialite::driver($provider)->stateless()->userFromToken($accessToken);
// Rest of code here
}
catch(Throwable $e){
dd(
$e->getMessage(),$e->getFile(),$e->getLine()
);
}
}
And Getting below error:
{“message”:”Client error:
GET https://www.googleapis.com/oauth2/v3/userinfo?prettyPrint=falseresulted in a401 Unauthorizedresponse:{“error”:”invalid_request”,”error_description”: “Invalid Credentials”}
Can anyone assist?