Skip to content
Snippets Groups Projects
Commit 7377dcd9 authored by Sigmund Augdal's avatar Sigmund Augdal
Browse files

authtwitter: Added support for fetching users email address as attribute

parent 76766c05
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 { ...@@ -43,6 +43,7 @@ class sspmod_authtwitter_Auth_Source_Twitter extends SimpleSAML_Auth_Source {
$this->key = $configObject->getString('key'); $this->key = $configObject->getString('key');
$this->secret = $configObject->getString('secret'); $this->secret = $configObject->getString('secret');
$this->force_login = $configObject->getBoolean('force_login', FALSE); $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 { ...@@ -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); $accessToken = $consumer->getAccessToken('https://api.twitter.com/oauth/access_token', $requestToken, $parameters);
SimpleSAML\Logger::debug("Got an access token from the OAuth service provider [" . SimpleSAML\Logger::debug("Got an access token from the OAuth service provider [" .
$accessToken->key . "] with the secret [" . $accessToken->secret . "]"); $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'])) { 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.'); 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