root() . '/'. $module. '/oauth/token'; $params = array_merge(config('passport.'. $config), [ 'username' => $username, 'password' => $password, 'provider' => $guard ]); $respond = $client->post($url, ['form_params' => $params]); } catch (RequestException $exception) { return false; } if ($respond->getStatusCode() === 401) { return false; } return json_decode($respond->getBody()->getContents(), true); } /** * 获取刷新token * @param string $module 模块 * @param string $config 配置 * @return boolean|mixed * @throws GuzzleException */ public function getRefreshToken(string $module, string $config): mixed { $client = new Client(); try { $url = request()->root() . '/'. $module. '/oauth/token'; $params = array_merge(config('passport.'. $config), [ 'refresh_token' => request('refresh_token'), ]); $response = $client->post($url, ['form_params' => $params]); } catch (RequestException $exception) { return false; } if ($response->getStatusCode() === 401) { return false; } return json_decode($response->getBody()->getContents(), true); } }