buildAuthUrlFromBase( $this->getBaseUrl() . '/oauth/authorize', $state, ); } protected function getTokenUrl(): string { return $this->getBaseUrl() . '/oauth/access_token'; } /** * @param string $token * @return array */ protected function getUserByToken($token): array { $response = $this->getHttpClient()->get( $this->getBaseUrl() . '/oauth/userinfo', [ RequestOptions::HEADERS => [ 'Authorization' => 'Bearer ' . $token, 'Accept' => 'application/json', ], ], ); return json_decode((string) $response->getBody(), true); } protected function mapUserToObject(array $user): User { return (new User())->setRaw($user)->map([ 'id' => $user['id'] ?? null, 'name' => $user['displayName'] ?? trim(($user['firstName'] ?? '') . ' ' . ($user['lastName'] ?? '')), 'email' => $user['email'] ?? null, 'avatar' => $user['imageUrl'] ?? null, ]); } }