Overtrue\Socialite\Providers\GitHubProvider::getEmailByToken PHP 메소드

getEmailByToken() 보호된 메소드

Get the email for the given access token.
protected getEmailByToken ( string $token ) : string | null
$token string
리턴 string | null
    protected function getEmailByToken($token)
    {
        $emailsUrl = 'https://api.github.com/user/emails?access_token=' . $token->getToken();
        try {
            $response = $this->getHttpClient()->get($emailsUrl, $this->getRequestOptions());
        } catch (Exception $e) {
            return;
        }
        foreach (json_decode($response->getBody(), true) as $email) {
            if ($email['primary'] && $email['verified']) {
                return $email['email'];
            }
        }
    }