簡體   English   中英

Laravel5.7 php 中的 Google 身份驗證並出現“缺少必需參數:代碼”錯誤 400

[英]Google Authentication in Laravel5.7 php and having “Missing required parameter: code” error 400

GuzzleHttp \\ Exception \\ ClientException (400) 客戶端錯誤: POST https://accounts.google.com/o/oauth2/token導致400 Bad Request響應:{ "error": "invalid_request", "error_description": "Missing必需參數:代碼" }

轉到vendor\\laravel\\socialite\\src\\Two\\GoogleProvider.php

打開GoogleProvider.php並從 $scopes protected $scopes = [ 'openid', 'email', ];刪除配置文件protected $scopes = [ 'openid', 'email', ]; 並檢查您的代碼現在正在運行。

遇到同樣的問題,是由於nginx配置錯誤

須藤納米 /etc/nginx/sites-available/default

它應該是,

location / {
try_files $uri $uri/ /index.php?$query_string;
}

它是,

location / {
try_files $uri $uri/ /index.php?query_string;
}

用“$query_string”替換了“query_string”,在我的例子中,query_string 沒有被定義為變量。

我找到了解決方案。 該錯誤表示在請求的 url 中找不到 code 參數。 您可以使用任何其他 get url 參數進行測試。 找不到您的參數數據。您缺少的是您的服務器沒有以任何形式的請求傳遞查詢參數。 如果您使用的是 nginx,請嘗試

location / {
            try_files $uri $uri/ /index.php?$args;                
       }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM