Closed yangwenqian closed 5 months ago
$socialite = new SocialiteManager(config('socialite')); $oauth = $socialite->create('gitee'); if (!Request::has('code')) { $url = $oauth->redirect(Request::fullUrl()); return redirect($url); } $user = $oauth->userFromCode(Request::input('code'));
提示:
production.ERROR: Client error: `POST https://gitee.com/oauth/token` resulted in a `401 Unauthorized` response: {"error":"invalid_request","error_description":"这个请求缺少必要的参数,或者参数值、格式不正确"} {"exception":"[object] (GuzzleHttp\\Exception\\ClientException(code: 401): Client error: `POST https://gitee.com/oauth/token` resulted in a `401 Unauthorized` response: {\"error\":\"invalid_request\",\"error_description\":\"这个请求缺少必要的参数,或者参数值、格式不正确\"}
找到原因了,gitee在userFromCode时还需要传一次redirect_uri,所以要么在config里配置redirect参数,要么
$user = $oauth->withRedirectUrl(Request::url())->userFromCode(Request::input('code'));
提示: