error parameter app_id is required - laravel

I installed Laravel5.5 Socialite 3.3, but can't make it work. It shows the error on the facebook page
parameter app_id is required.

You should try this:
Please check below code in config/service.php:
'facebook' => [
'client_id' => '222221956976734',
'client_secret' => 'a5acf8e8e01745d47rer829a0094vfvf',
'redirect' => 'http://localhost/myproject/public/callback',
],
Or more details please follow this link

Related

How can I solve redirect error of Laravel Socialite?

I installed socialite to laravel project? But I have to change redirect url of google. Even though I changed url from google console and defined new client Id, client secret and url at config/services.php, I have problem when login with google that redirecting me to old url. What can be cause this error? We also clear the cache, but problem continues.. If you give me an idea, I will very appreciated.
return [
....
'google' => [
'client_id' => 'app id',
'client_secret' => 'add secret',
'redirect' => 'https://.../auth/google/callback',
],
]

Generate both access and refresh tokens in Laravel login

Im trying to implement authentication in laravel using passport.
I need to create a New accessToken and refreshToken once the user logs in.
Now, following Laravel's documentation, it can be donde like this:
use Illuminate\Support\Facades\Http;
$response = Http::asForm()->post('http://passport-app.test/oauth/token', [
'grant_type' => 'password',
'client_id' => 'client-id',
'client_secret' => 'client-secret',
'username' => 'taylor#laravel.com',
'password' => 'my-password',
'scope' => '',
]);
return $response->json();
The workaround here would be to make an API endpoint that would basically take the user's credentials and post them with the other required data to the above endpoint.
Is it OK to call a route of my own API from another route or my API?. It feels like it should be a better way to do this. Can someone point me to that way if it exists or if there is a better implementation?
Thanks in advance!
If you are using OpenID-Connect, you should always ask for the openid scope.
To get a refresh token, you also need to ask for the offline_access scope.
Like
'scope' => 'openid offline_access',

Laravel socialite dynamic redirectUrl not working in multi-tenant app

i have a multi-tenant app and i am trying to add Facebook linking in it i have tried the process using laravel socialite but i have a problem that when i use dynamic redirect url like so
return Socialite::driver('facebook')
->with([
'redirect_uri' => "https://" . $dynamichost . "/social/facebook/callback",
])
->redirect();
or this way
return Socialite::driver('facebook')->redirectUrl('https://' . $dynamichost .
'/social/facebook/callback')->redirect();
facebook returns error url mismatch. Note i also have set a value for redirect_url in .env
then i have services values like this
'facebook' => [
'client_id' => env('FACEBOOK_APP_ID'),
'client_secret' => env('FACEBOOK_APP_SECRET'),
'redirect' => env('CALLBACK_URL_FACEBOOK'),
'default_graph_ve`enter code here`rsion' => 'v3.3',
],
my guess is socialite somehow set the redirect url equal to the value which is coming from .env and when i change it dynamically it still thinks that url will be like the value of .env and i have tested this scenario the request get success response if keep the redirect url static.
Any suggestions how can i overcome this. thanks.
if you want to use custom redirect-uri dynamic :
use Socialite;
use Laravel\Socialite\Two\FacebookProvider;
$socialite = Socialite::buildProvider(
FacebookProvider::class, [
'client_id' => 'your_id',
'client_secret' => 'your_secret',
'redirect' => 'url',
'default_graph_version' => 'v3.3', //not sure if this needed as far as i know, in socialite the version is defined
]
)->redirect();
well it was dumb mistake i had to match the redirect url in callback handling method. its fixed now thanks.

I got Unable to resolve PSR request error with GuzzleHttp request

Implementing in my Laravel 7.6 app(pt hosts at http://local-votes.com of my local OS) api for
external api I want to make a test request from my other
Laravel 6.17.1 app and reading here : https://laravel.com/docs/7.x/passport
Converting Authorization Codes To Access Tokens
I try to use this example:
$http = new \GuzzleHttp\Client;
$client_id= 3; // client ID I made in my host app
$client_secret= 'XXX'; // client secret I made in my host app
$host= 'http://local-votes.com';
$response = $http->post($host.'/oauth/token', [
'form_params' => [
'grant_type' => 'authorization_code',
'client_id' => $client_id,
'client_secret' => $client_secret,
'redirect_uri' => $host.'/votes',
'code' => 'code',
// 'code' => $request->code,
],
]);
But I got error :
Illuminate\Contracts\Container\BindingResolutionException: Unable to resolve PSR request. Please i (truncated...)
{"userId":5,"exception":"[object] (GuzzleHttp\\Exception\\ServerException(code: 500): Server error: `POST http://local-votes.com/oauth/token` resulted in a `500 Internal Server Error` response:
Also I am not sure which values have I provide for fields 'client_secret' and 'code' ?
Can it be the issue ?
How to fix this error ?
Thanks!
Installing package nyholm/psr7
on provider app salved the problem!

Laravel Socialite "Facebook" The parameter app_id is required

So I am having the same problem as this user here : Laravel Socialite Facebook Login Error: The parameter app_id is required
and I have followed the solution give to this user. but I still get the same error.
even tried changing clinet_id to app_id.. nothing has changed the same error
The parameter app_id is required
'facebook' => [
'client_id' => 'hidden', //Facebook App Client ID
'client_secret' => 'hidden', // Your Facebook App Client Secret
'redirect' => 'http://localhost:8000/login/facebook/callback', // Your application route used to redirect users back to your app after authentication
],
route:
Route::get('login/facebook', 'Auth\LoginController#redirectToProvider');
Route::get('login/facebook/callback', 'Auth\LoginController#handleProviderCallback');
I cant see whats wrong here. added everything. from the documentation. in service the facade. what can be my mistake here? I feel its fairly obvious but I cant see it
you have to set app id, secret and call back url in config file so open config/services.php and .env file then set id and secret this way:
'facebook' => [
'client_id' => env('FACEBOOK_CLIENT_ID'),
'client_secret' => env('FACEBOOK_CLIENT_SECRET'),
'redirect' => env('FACEBOOK_CALLBACK_URL'),
],
.env
FACEBOOK_CLIENT_ID=xxxxxxxxx
FACEBOOK_CLIENT_SECRET=xxxxxxx
FACEBOOK_CALLBACK_URL=http://localhost:8000/login/facebook/callback
After completion of .env edit please enter this command in your terminal for clear cache:php artisan config:cache

Resources