src/Two/BitbucketProvider.php
protected function getEmailByToken($token)
    {
        $emailsUrl = 'https://api.bitbucket.org/2.0/user/emails?access_token='.$token;

        try {
            $response = $this->getHttpClient()->get($emailsUrl);
        } catch (Exception $e) {
            return null;
        }

        $emails = json_decode($response->getBody(), true);

        foreach ($emails['values'] as $email) {
            if ($email['type'] == 'email' && $email['is_primary'] && $email['is_confirmed']) {
                return $email['email'];
            }
        }
    }
protected function getEmailByToken($token)
    {
        $emailsUrl = 'https://api.bitbucket.org/2.0/user/emails?access_token='.$token;

        try {
            $response = $this->getHttpClient()->get($emailsUrl);
        } catch (Exception $e) {
            return null;
        }

        $emails = json_decode($response->getBody(), true);

        foreach ($emails['values'] as $email) {
            if ($email['type'] == 'email' && $email['is_primary'] && $email['is_confirmed']) {
                return $email['email'];
            }
        }
    }
protected function getEmailByToken ( $ token ) { $ emailsUrl = 'https://api.bitbucket.org/2.0/user/emails?access_token=' . $ token ; try { $ response = $ this -> getHttpClient ( ) -> get ( $ emailsUrl ) ; } catch ( Exception $ e ) { return null ; } $ emails = json_decode ( $ response -> getBody ( ) , true ) ; foreach ( $ emails [ 'values' ] as $ email ) { if ( $ email [ 'type' ] == 'email' && $ email [ 'is_primary' ] && $ email [ 'is_confirmed' ] ) { return $ email [ 'email' ] ; } } }
Get the email for the given access token.

@param  string  $token
@return string|null
Get the email for the given access token .