When I try to login with google using the Laravel Socialite package, it
returns an error saying missing required paramater Client_ID. I have
defined the id in my .env file and called it here in my services.php file. Not sure why this error is happening. Any assistance with this would be greatly appreciated. Thank you.
My services.php file:
'google' => [
'client_id' => env('GOOGLE_ID'),
'client_secret' => env('GOOGLE_SECRET'),
'redirect' => env('GOOGLE_URL'),
],
My .env file:
GOOGLE_ID=xxxxxxxxxx
GOOGLE_SECRET=xxxxx
GOOGLE_URL=URL/login/google/callback
Related
I recently upgraded my Laravel from 5.7.29 to 8.51. I have been using the Mailgun API to send emails for years. The old version of the site is still able to send via mailgun, but the new version keeps returning this message:
Client error: `POST https://api.mailgun.net/v3/mg.clstracking.com/messages.mime` resulted in a `401 Unauthorized` response: Forbidden
I found similar posts that indicate that kind of response if you're working in the EU and fail to change the MAILGUN_ENDPOINT in the services config. The server and site are all in the USA. I have verified I have the correct settings in my .env and that those are passed into my services.php config file and cached using artisan config:cache. I verified this by looking through the /bootstrap/cache/config.php and everything is there - I even checked this against another site with a different domain that is working the same way. I even tried hard-coding my domain and secret into the services.php.
If I change
MAIL_MAILER=smtp
MAIL_HOST=smtp.mailtrap.io
with my username and password, I get no error, but the email isn't sent and checking the logs on mailgun, there is no record. I'm at a loss what else to try.
In env I have:
MAIL_MAILER=mailgun
MAILGUN_DOMAIN=mg.mydomain.com
MAILGUN_SECRET=key-##########################
In config/services.php:
'mailgun' => [
'domain' => env('MAILGUN_DOMAIN'),
'secret' => env('MAILGUN_SECRET'),
'endpoint' => env('MAILGUN_ENDPOINT', 'api.mailgun.net'),
],
In config/mail.php:
'default' => env('MAIL_MAILER', 'mailgun'),
'mailers' => [
'mailgun' => [
'transport' => 'mailgun',
],
],
I use this config in my projects which are in production with gmail
MAIL_MAILER='sendmail'
MAIL_HOST='sendmail.googlemail.com'
MAIL_PORT=587
MAIL_USERNAME='email#gmail.com'
MAIL_PASSWORD="*********"
MAIL_ENCRYPTION='tls'
MAIL_FROM_ADDRESS='email#gmail.com'
MAIL_FROM_NAME="${APP_NAME}"
Maybe helps you.
I've been trying to create an access_token for my api. I've followed the setup and am using Postman to test/create a token. I can't seem to get past an invalid_grant error.
I've tried what seems like every combination I've been able to find without any luck. Here is my setup:
Sending a POST request to: http://mywebsite.local/oauth/token
In the body, I am setting form-data to this (name/value):
grant_type password
client_id 1
client_secret <super_long_string>
username my#email.com
password secret
I've used tinker to create a dummy user:
factory('App\User')->create()
I use the newly created user for my username/password above.
Regardless of what I'm doing (short of not passing anything) this is the error I'm always seeing:
{
"error": "invalid_grant",
"error_description": "The provided authorization grant (e.g., authorization code, resource owner credentials) or refresh token is invalid, expired, revoked, does not match the redirection URI used in the authorization request, or was issued to another client.",
"hint": "",
"message": "The provided authorization grant (e.g., authorization code, resource owner credentials) or refresh token is invalid, expired, revoked, does not match the redirection URI used in the authorization request, or was issued to another client."
}
I've read many times this means the grant_type I'm trying to get doesn't match up to the client. I'm using php artisan passport:client --password to create the client, so I don't understand why it's invalid. I only have one client, so I know I'm using the correct id. This issue seems like the same thing, I am seeing but has since been closed.
For my headers I'm only setting Content-Type application/json, and I have nothing set for Authorization headers.
I'm not sure what else to try. Thank you for any suggestions!
as it is stated here, from the 5.8 version the default password "secret" has beeen updated to "password". so you are entering the old password.
Try to hash your password for the user.
At first I think the password needs to be at least 8 characters long.
Then, e.g. if you use "test1234" as the password for the created user, go to your terminal and type:
>> php artisan tinker
>> echo bcrypt('test1234')
Copy the output and save it in the password database column of your created user instead of test1234. Now your post request to http://mywebsite.local/oauth/token should work.
I faced the same problem in laravel 8 and I solve it by reinstalling laravel passport
these are the steps:
1- comment this line in AuthServiceProvider.php
if (! $this->app->routesAreCached()) {
//Passport::routes();
}
2- in composer.json delete this following line:
"laravel/passport": "^xx.x",
3- run these commands:
composer dump-autoload
composer update
php artisan migrate:fresh
now we are going to install laravel passport
4- run these commands:
composer require laravel/passport
php artisan migrate
php artisan passport:install --force
5- in AuthServiceProvider.php add these lines:
use Laravel\Passport\Passport;
class AuthServiceProvider extends ServiceProvider
{
protected $policies = [
'App\Models\Model' => 'App\Policies\ModelPolicy',
];
public function boot()
{
$this->registerPolicies();
if (! $this->app->routesAreCached()) {
Passport::routes();
}
}
}
6- in config\auth.php add these codes:
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'api' => [
'driver' => 'passport',
'provider' => 'users',
],
],
finish, after these steps, laravel-passport is working well
I have an issue with Socialite on Laravel 5.5 I have Socialite required by composer, updated services.php with different providers credential and updated providers in app.php This is the error I am getting
Type error: Argument 1 passed to Laravel\Socialite\SocialiteManager::formatRedirectUrl() must be of the type array, null given
Any help is highly appreciated.
In most of the cases, the issue is solved through 3 steps:
Run php artisan clear-compiled
Run composer dump-autoload
Run php artisan optimize
Hope it helps. Thanks.
Check config/services.php for the provider you're authenticating with. The redirect entry needs to be set to your defined route.
'redirect' => 'http://your-callback-url'
Example:
// config.services.php
'github' => [
'client_id' => env('GITHUB_CLIENT_ID'),
'client_secret' => env('GITHUB_CLIENT_SECRET'),
'redirect' => 'http://example.com/github/redirect',
],
// routes/web.php
Route::get('github/redirect', 'GitHubController#redirect')
I have a fundraising platform built with Laravel 5.4. I've been successful in removing the public from the URL and hiding both the .env and composer.json files from view, but I can't upload an avatar to the upload/avatar folder from the admin or user account because Laravel produces a public/uploads/avatar folder and uploads the avatar into it instead of into the upload/avatar folder where it needs to go.
I have tried updating routes and usercontroller but to no avail. I'm not sure where to look now.
Can someone help me out with telling me where I go to change the code so Laravel no longer produces a public/uploads/avatar folder when I upload an avatar so the avatar goes into the upload/avatar folder instead?
Thanks.
In Filesystems.php
Change this:
'public' => [
'driver' => 'local',
'root' => public_path(),
],
To this:
'public' => [
'driver' => 'local',
'root' => '/',
],
Using composer, I have installed Socialite package to my local machine. It works well. Then I upload all the vendor/laravel/socialite directory as it is to server. Then on server, in composer.json added the line -
"laravel/socialite": "^2.0"
Also, in config/app.php make below changes -
In provider section add the line -
Laravel\Socialite\SocialiteServiceProvider::class,
In aliases section add this line -
'Socialite' => Laravel\Socialite\Facades\Socialite::class,
Then, as per documentation add below code in config/services.php file -
'facebook' => [
'client_id' => '{{my_client_id}}',
'client_secret' => '{{my_secret_key}}',
'redirect' => 'http://mydomain/public/callback',
],
The Controller, I am using has included use Socialite; at top.
Bur now, it gives me error as Class 'Socialite' not found on server. Where as it works fine on my local machine.
Am I missing something to upload on server?
Your help is appreciated.
Thanks.
You need to do dump autoload everytime you make changes in composer.json, composer dump-auto