Skip to content

Commit

Permalink
TwitterProvider(OAuth1) additional query string (#162)
Browse files Browse the repository at this point in the history
* TwitterProvider(OAuth1) additional query string

TwitterProvider(Oauth1) doesn't compatible an additional query string regardless of having a method with().

Laracast discussion 'Is it possible to use force_login for Twitter in Laravel Socialite?'.
https://laracasts.com/discuss/channels/laravel/is-it-possible-to-use-force-login-for-twitter-in-laravel-socialite

I updating method getAuthorizationUrl().
It allows additional query strings like calling with(['fource_url'=>true]) options as well as ['lang' => 'ja'] option.

if 'SocialiteProviders\Manager\OAuth1\Server' add this function, It might be compatible any other OAuth1 providers.
Please review it. thx.

* Cord formatting.
  • Loading branch information
tomothumb authored and faustbrian committed Apr 23, 2018
1 parent b10f7aa commit 9572f58
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,25 @@ public function userScreenName($data, TokenCredentials $tokenCredentials)
{
return $data['screen_name'];
}

/**
* {@inheritdoc}
*/
public function getAuthorizationUrl($temporaryIdentifier)
{
// Somebody can pass through an instance of temporary
// credentials and we'll extract the identifier from there.
if ($temporaryIdentifier instanceof TemporaryCredentials) {
$temporaryIdentifier = $temporaryIdentifier->getIdentifier();
}
$query_oauth_token = ['oauth_token' => $temporaryIdentifier];
$parameters = (isset($this->parameters))
? array_merge($query_oauth_token, $this->parameters)
: $query_oauth_token;

$url = $this->urlAuthorization();
$queryString = http_build_query($parameters);

return $this->buildUrl($url, $queryString);
}
}

1 comment on commit 9572f58

@egorsgor
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, this commit broke my authorization.

TemporaryCredentials is undefined class (need add use .. ) and for this reason $temporaryIdentifier is a object, http_build_query return empty string and i get this auth link: "https://api.twitter.com/oauth/authenticate?"

Please sign in to comment.