@JeffreyWay @TaylorOtwell here is what I've run into with Socialite:
GitHub: if you don't have a GitHub name field as you've not entered one on GitGub, Socialite will fail on the
protected function mapUserToObject(array $user)
{
return (new User)->setRaw($user)->map([
'id' => $user['id'], 'nickname' => $user['login'], 'name' => $user['name'],
'email' => $user['email'], 'avatar' => $user['avatar_url'],
]);
}
Need a isset check somewhere:
(isset($userSocialData->user['name'])) ? $userArray['name'] = $userSocialData->user['name'] : $userArray['name'] = "";
LinkedIn: Although there is no provider for LinkedIn I attempted to use refactor a Facebook version as LinkedIn takes similar params:
https://www.linkedin.com/uas/oauth2/authorization?response_type=code
&client_id=YOUR_API_KEY
&scope=SCOPE
&state=STATE
&redirect_uri=YOUR_REDIRECT_URI
However, passing these through returns a ERROR_DECODING 500. It seems that there is a gzip (chrome) / header compression issue, but could not solve for it.
Twitter:
I spent 5 hours today debugging this and still don't have an answer but here is what I learned. The twitter provider extends the oauth one provider in One. When you invoke the redirect() method i.e.
$this->socialite->driver('twitter')->redirect();
it calls this method, which set a temp 'oauth.temp' value with temp credentials. You will end up at the twitter authorize page. If you, as the user, authorize it will return a 'oauth_token' && 'oauth_verifier'
public function redirect()
{
$this->request->getSession()->set(
'oauth.temp', $temp = $this->server->getTemporaryCredentials()
);
return new RedirectResponse($this->server->getAuthorizationUrl($temp));
}
however, somewhere at the same time it returns the code and verifier it does another request and rewrites the temp values in session. However, I don't see how as it is not making a call to the above. Also, if it bombs out it still has the old values in Session so you sometimes end up with problems unless you write some flush Session.
so when you do a auth user() call and it calls the getTokenCredentials method the temp values no longer match and you end up with a mismatch error or I get a null passed through to temp:
public function getTokenCredentials(TemporaryCredentials $temporaryCredentials, $temporaryIdentifier, $verifier)
{
if ($temporaryIdentifier !== $temporaryCredentials->getIdentifier()) {
throw new \InvalidArgumentException(
"Temporary identifier passed back by server does not match that of stored temporary credentials.
Potential man-in-the-middle."
);
}
$uri = $this->urlTokenCredentials();
$bodyParameters = array('oauth_verifier' => $verifier);
$client = $this->createHttpClient();
$header = $this->protocolHeader('POST', $uri, $temporaryCredentials, $bodyParameters);
try {
$response = $client->post($uri, array(
'Authorization' => $header,
), $bodyParameters)->send();
} catch (BadResponseException $e) {
return $this->handleTokenCredentialsBadResponse($e);
}
return $this->createTokenCredentials($response->getBody());
}
Hope this helps. Let me know if you have any solutions.