2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

LaravelのGoogleログインの実装で「エラー 400: invalid_request」となる

Posted at

問題点

ローカルホストでgoogleログインをしようとしたら、Googleのclient_idが読み取れてないというエラーが出た。
スクリーンショット 2020-05-05 20.50.11.png

環境

Laravel 6.8
PHP 7.4
Docker
laravel/socialite 3.2
Google API Consoleの設定完了済み ↓↓
https://console.developers.google.com/project

解決方法

services.phpの google設定方法を変える

×上手くいかなかった設定方法
    'google' => [
        'client_id' => env('〇〇.apps.googleusercontent.com'),
        'client_secret' => env('〇〇'),
        'redirect' => env('APP_URL') . '/login/google/callback',
    ],
○上手くいった設定方法
    'google' => [
        'client_id' => '〇〇.apps.googleusercontent.com',
        'client_secret' => '〇〇',
        'redirect' => 'http://localhost/login/google/callback',
    ],

どうやら env()に囲まれた状態だと読み取られないことがあるようだったので、そちらを外しました!

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?