Skip to content
Snippets Groups Projects
Commit 0589bd3f authored by Jaime Pérez Crespo's avatar Jaime Pérez Crespo Committed by GitHub
Browse files

Merge pull request #578 from sigmunau/master

authtwitter: Added support for fetching users email address as attribute
parents 76766c05 7377dcd9
No related branches found
No related tags found
No related merge requests found
......@@ -43,6 +43,7 @@ class sspmod_authtwitter_Auth_Source_Twitter extends SimpleSAML_Auth_Source {
$this->key = $configObject->getString('key');
$this->secret = $configObject->getString('secret');
$this->force_login = $configObject->getBoolean('force_login', FALSE);
$this->include_email = $configObject->getBoolean('include_email', FALSE);
}
......@@ -103,8 +104,12 @@ class sspmod_authtwitter_Auth_Source_Twitter extends SimpleSAML_Auth_Source {
$accessToken = $consumer->getAccessToken('https://api.twitter.com/oauth/access_token', $requestToken, $parameters);
SimpleSAML\Logger::debug("Got an access token from the OAuth service provider [" .
$accessToken->key . "] with the secret [" . $accessToken->secret . "]");
$userdata = $consumer->getUserInfo('https://api.twitter.com/1.1/account/verify_credentials.json', $accessToken);
$verify_credentials_url = 'https://api.twitter.com/1.1/account/verify_credentials.json';
if ($this->include_email) {
$verify_credentials_url = $verify_credentials_url . '?include_email=true';
}
$userdata = $consumer->getUserInfo($verify_credentials_url, $accessToken);
if (!isset($userdata['id_str']) || !isset($userdata['screen_name'])) {
throw new SimpleSAML_Error_AuthSource($this->authId, 'Authentication error: id_str and screen_name not set.');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment