if (isset($_GET['code'])) {
try {
// fetch access_token
- $request = new HTTPRequest('https://graph.facebook.com/oauth/access_token?client_id='.FACEBOOK_PUBLIC_KEY.'&redirect_uri='.rawurlencode($callbackURL).'&client_secret='.FACEBOOK_PRIVATE_KEY.'&code='.rawurlencode($_GET['code']));
+ $request = new HTTPRequest('https://graph.facebook.com/oauth/access_token?client_id='.StringUtil::trim(FACEBOOK_PUBLIC_KEY).'&redirect_uri='.rawurlencode($callbackURL).'&client_secret='.StringUtil::trim(FACEBOOK_PRIVATE_KEY).'&code='.rawurlencode($_GET['code']));
$request->execute();
$reply = $request->getReply();
// start auth by redirecting to facebook
$token = StringUtil::getRandomID();
WCF::getSession()->register('__facebookInit', $token);
- HeaderUtil::redirect("https://www.facebook.com/dialog/oauth?client_id=".FACEBOOK_PUBLIC_KEY. "&redirect_uri=".rawurlencode($callbackURL)."&state=".$token."&scope=email,user_about_me,user_birthday,user_interests,user_location,user_website");
+ HeaderUtil::redirect("https://www.facebook.com/dialog/oauth?client_id=".StringUtil::trim(FACEBOOK_PUBLIC_KEY). "&redirect_uri=".rawurlencode($callbackURL)."&state=".$token."&scope=email,user_about_me,user_birthday,user_interests,user_location,user_website");
$this->executed();
exit;
}
try {
// fetch access_token
$request = new HTTPRequest('https://github.com/login/oauth/access_token', array(), array(
- 'client_id' => GITHUB_PUBLIC_KEY,
- 'client_secret' => GITHUB_PRIVATE_KEY,
+ 'client_id' => StringUtil::trim(GITHUB_PUBLIC_KEY),
+ 'client_secret' => StringUtil::trim(GITHUB_PRIVATE_KEY),
'code' => $_GET['code']
));
$request->execute();
// start auth by redirecting to github
$token = StringUtil::getRandomID();
WCF::getSession()->register('__githubInit', $token);
- HeaderUtil::redirect("https://github.com/login/oauth/authorize?client_id=".rawurlencode(GITHUB_PUBLIC_KEY)."&scope=".rawurlencode('user:email')."&state=".$token);
+ HeaderUtil::redirect("https://github.com/login/oauth/authorize?client_id=".rawurlencode(StringUtil::trim(GITHUB_PUBLIC_KEY))."&scope=".rawurlencode('user:email')."&state=".$token);
$this->executed();
exit;
}
// fetch access_token
$request = new HTTPRequest('https://accounts.google.com/o/oauth2/token', array(), array(
'code' => $_GET['code'],
- 'client_id' => GOOGLE_PUBLIC_KEY,
- 'client_secret' => GOOGLE_PRIVATE_KEY,
+ 'client_id' => StringUtil::trim(GOOGLE_PUBLIC_KEY),
+ 'client_secret' => StringUtil::trim(GOOGLE_PRIVATE_KEY),
'redirect_uri' => $callbackURL,
'grant_type' => 'authorization_code'
));
// start auth by redirecting to google
$token = StringUtil::getRandomID();
WCF::getSession()->register('__googleInit', $token);
- HeaderUtil::redirect("https://accounts.google.com/o/oauth2/auth?client_id=".rawurlencode(GOOGLE_PUBLIC_KEY). "&redirect_uri=".rawurlencode($callbackURL)."&state=".$token."&scope=https://www.googleapis.com/auth/userinfo.profile+https://www.googleapis.com/auth/userinfo.email&response_type=code");
+ HeaderUtil::redirect("https://accounts.google.com/o/oauth2/auth?client_id=".rawurlencode(StringUtil::trim(GOOGLE_PUBLIC_KEY)). "&redirect_uri=".rawurlencode($callbackURL)."&state=".$token."&scope=https://www.googleapis.com/auth/userinfo.profile+https://www.googleapis.com/auth/userinfo.email&response_type=code");
$this->executed();
exit;
}
try {
// fetch access_token
$oauthHeader = array(
- 'oauth_consumer_key' => TWITTER_PUBLIC_KEY,
+ 'oauth_consumer_key' => StringUtil::trim(TWITTER_PUBLIC_KEY),
'oauth_nonce' => StringUtil::getRandomID(),
'oauth_signature_method' => 'HMAC-SHA1',
'oauth_timestamp' => TIME_NOW,
));
$oauthHeader = array(
'oauth_callback' => $callbackURL,
- 'oauth_consumer_key' => TWITTER_PUBLIC_KEY,
+ 'oauth_consumer_key' => StringUtil::trim(TWITTER_PUBLIC_KEY),
'oauth_nonce' => StringUtil::getRandomID(),
'oauth_signature_method' => 'HMAC-SHA1',
'oauth_timestamp' => TIME_NOW,
}
$base = "POST&".rawurlencode($url)."&".rawurlencode($parameterString);
- $key = rawurlencode(TWITTER_PRIVATE_KEY).'&'.rawurlencode($tokenSecret);
+ $key = rawurlencode(StringUtil::trim(TWITTER_PRIVATE_KEY)).'&'.rawurlencode($tokenSecret);
return base64_encode(hash_hmac('sha1', $base, $key, true));
}
$user = new User($row['userID']);
return $user;
}
-}
+}
\ No newline at end of file