getBaseUrl(); } /** * {@inheritdoc} */ protected function getAuthUrl($state): string { return $this->buildAuthUrlFromBase( $this->getBaseUrl() . '/oauth/authorize', $state ); } /** * {@inheritdoc} */ protected function getTokenUrl(): string { return $this->getBaseUrl() . '/oauth/token'; } /** * {@inheritdoc} * * @throws GuzzleException */ protected function getUserByToken($token) { $response = $this->getHttpClient()->get( $this->getBaseUrl() . '/api/v1/user', [ 'headers' => [ 'Accept' => 'application/json', 'Authorization' => 'Bearer ' . $token, ], ]); return json_decode($response->getBody()->getContents(), true)['data']; } /** * {@inheritdoc} */ protected function mapUserToObject(array $user): \Laravel\Socialite\Two\User|User { return (new User())->setRaw($user)->map([ 'id' => $user['id'], 'nickname' => $user['username'], 'name' => $user['name'], 'email' => Arr::get($user, 'email'), 'avatar' => $user['avatar'], ]); } /** * {@inheritdoc} */ protected function getTokenFields($code): array { return array_merge(parent::getTokenFields($code), [ 'grant_type' => 'authorization_code', ]); } /** * Returns the user logout url for the provider. */ public function getLogoutUrl(string $redirect = null): string { return app(AnikeenId::class)->getBaseUrl() . '/logout?redirect=' . urlencode($redirect ?: '/'); } }