forked from hwi/HWIOAuthBundle
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
93 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the HWIOAuthBundle package. | ||
* | ||
* (c) Hardware.Info <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace HWI\Bundle\OAuthBundle\OAuth\ResourceOwner; | ||
|
||
/** | ||
* YahooResourceOwner | ||
* | ||
* @author Tom <[email protected]> | ||
* @author Alexander <[email protected]> | ||
*/ | ||
class YahooResourceOwner extends GenericOAuth1ResourceOwner | ||
{ | ||
/** | ||
* {@inheritDoc} | ||
*/ | ||
protected $options = array( | ||
'authorization_url' => 'https://api.login.yahoo.com/oauth/v2/request_auth', | ||
'request_token_url' => 'https://api.login.yahoo.com/oauth/v2/get_request_token', | ||
'access_token_url' => 'https://api.login.yahoo.com/oauth/v2/get_token', | ||
'infos_url' => 'http://social.yahooapis.com/v1/user/{guid}/profile', | ||
'user_response_class' => '\HWI\Bundle\OAuthBundle\OAuth\Response\PathUserResponse', | ||
'realm' => 'yahooapis.com', | ||
); | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
protected $paths = array( | ||
'username' => 'profile.guid', | ||
'displayname' => 'profile.nickname', | ||
); | ||
|
||
/** | ||
* Override to replace {guid} in the infos_url with the authenticating user's yahoo id | ||
* {@inheritDoc} | ||
*/ | ||
public function getUserInformation($accessToken) | ||
{ | ||
$this->options['infos_url'] = str_replace('{guid}', $accessToken['xoauth_yahoo_guid'], $this->getOption('infos_url')); | ||
return parent::getUserInformation($accessToken); | ||
} | ||
|
||
/** | ||
* Override to set the Accept header as otherwise Yahoo defaults to XML | ||
* {@inheritDoc} | ||
*/ | ||
protected function doGetUserInformationRequest($url, array $parameters = array()) | ||
{ | ||
return $this->httpRequest($url, null, $parameters, array('Accept: application/json'), 'GET'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
Step 2x: Setup Yahoo | ||
======================= | ||
First you will have to register your application on Yahoo ("Create a Project"). Check out the | ||
documentation for more information: http://developer.yahoo.com/oauth/. | ||
|
||
The Yahoo Resource Owner uses the Yahoo Profile API to get user information, so when setting up your Yahoo Project | ||
you must ensure that you have enabled access to the "Social Directory" service, with at least "Read Public" access | ||
under the "Social Directory (Profiles)" section. | ||
|
||
Next configure a resource owner of type `yahoo` with appropriate `client_id`, | ||
`client_secret`. | ||
|
||
``` yaml | ||
# app/config.yml | ||
|
||
hwi_oauth: | ||
resource_owners: | ||
any_name: | ||
type: yahoo | ||
client_id: <client_id> | ||
client_secret: <client_secret> | ||
``` | ||
When you're done. Continue by configuring the security layer or go back to | ||
setup more resource owners. | ||
- [Step 2: Configuring resource owners (Facebook, GitHub, Google, Windows Live and others](2-configuring_resource_owners.md) | ||
- [Step 3: Configuring the security layer](3-configuring_the_security_layer.md). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters