PHPackages                             hayageek/oauth2-yahoo - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. hayageek/oauth2-yahoo

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

hayageek/oauth2-yahoo
=====================

Yahoo OAuth 2.0 Client Provider for The PHP League OAuth2-Client

2.0.5(7y ago)7191.0k↓33.9%14[3 PRs](https://github.com/hayageek/oauth2-yahoo/pulls)4MITPHP

Since Sep 22Pushed 6y ago1 watchersCompare

[ Source](https://github.com/hayageek/oauth2-yahoo)[ Packagist](https://packagist.org/packages/hayageek/oauth2-yahoo)[ RSS](/packages/hayageek-oauth2-yahoo/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (4)Versions (9)Used By (4)

Yahoo Provider for OAuth 2.0 Client
===================================

[](#yahoo-provider-for-oauth-20-client)

[![Build Status](https://camo.githubusercontent.com/6098e3f9a6dce5ae27ec1a0a85d9f12ec830856292bf9ef970646acf5dbc3fc5/68747470733a2f2f7472617669732d63692e6f72672f686179616765656b2f6f61757468322d7961686f6f2e737667)](https://travis-ci.org/hayageek/oauth2-yahoo)[![Coverage Status](https://camo.githubusercontent.com/cb84b7552b51a99b1f7ec705d85a5f24aa93e909293a16743d06e786a21a6aa0/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f686179616765656b2f6f61757468322d7961686f6f2f62616467652e7376673f6272616e63683d6d617374657226736572766963653d676974687562)](https://coveralls.io/github/hayageek/oauth2-yahoo?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/9349244b42442b451921f9a2d9f66b72d49727ba66efb39588c2c666d293ceea/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f686179616765656b2f6f61757468322d7961686f6f2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/hayageek/oauth2-yahoo/?branch=master)

This package provides Yahoo OAuth 2.0 support for the PHP League's [OAuth 2.0 Client](https://github.com/thephpleague/oauth2-client).

This package is compliant with [PSR-1](https://www.php-fig.org/psr/psr-1/), [PSR-2](https://www.php-fig.org/psr/psr-2/) and [PSR-4](https://www.php-fig.org/psr/psr-4/). If you notice compliance oversights, please send a patch via pull request.

Requirements
------------

[](#requirements)

The following versions of PHP are supported.

- PHP 5.6
- PHP 7.0
- PHP 7.1
- HHVM

Installation
------------

[](#installation)

To install, use composer:

```
composer require hayageek/oauth2-yahoo

```

Usage
-----

[](#usage)

### Authorization Code Flow

[](#authorization-code-flow)

```
session_start();
require('vendor/autoload.php');

$provider = new Hayageek\OAuth2\Client\Provider\Yahoo([
    'clientId'     => '{Yahoo-app-id}',
    'clientSecret' => '{Yahoo-app-secret}',
    'redirectUri'  => 'https://example.com/callback-url',
]);

if (!empty($_GET['error'])) {

    // Got an error, probably user denied access
    exit('Got error: ' . $_GET['error']);

} elseif (empty($_GET['code'])) {

    // If we don't have an authorization code then get one
    $authUrl = $provider->getAuthorizationUrl();
    // If we want to set approve page language (default is 'en-us')
    // $authUrl = $provider->getAuthorizationUrl(['language' => 'zh-tw']);
    $_SESSION['oauth2state'] = $provider->getState();
    header('Location: ' . $authUrl);
    exit;

} elseif (empty($_GET['state']) || ($_GET['state'] !== $_SESSION['oauth2state'])) {

    // State is invalid, possible CSRF attack in progress
    unset($_SESSION['oauth2state']);
    exit('Invalid state');

} else {

    // Try to get an access token (using the authorization code grant)
    $token = $provider->getAccessToken('authorization_code', [
        'code' => $_GET['code']
    ]);

    // Optional: Now you have a token you can look up a users profile data
    try {

        // We got an access token, let's now get the owner details
        $ownerDetails = $provider->getResourceOwner($token);

        //Use these details to create a new profile
        echo 'Name: '.$ownerDetails->getName()."";
	    echo 'FirstName: '.$ownerDetails->getFirstName()."";
    	echo 'Lastname: '.$ownerDetails->getLastName()."";

	    echo 'Email: '.$ownerDetails->getEmail()."";
	    echo 'Image: '.$ownerDetails->getAvatar()."";

    } catch (Exception $e) {

        // Failed to get user details
        exit('Something went wrong: ' . $e->getMessage());

    }

	// Use this to interact with an API on the users behalf
	echo "Token: ". $token->getToken()."";

	// Use this to get a new access token if the old one expires
	echo  "Refresh Token: ".$token->getRefreshToken()."";

	// Number of seconds until the access token will expire, and need refreshing
	echo "Expires:" .$token->getExpires()."";

}
```

### Refreshing a Token

[](#refreshing-a-token)

```
$provider = new Hayageek\OAuth2\Client\Provider\Yahoo([
    'clientId'     => '{Yahoo-app-id}',
    'clientSecret' => '{Yahoo-app-secret}',
    'redirectUri'  => 'https://example.com/callback-url',
]);

$grant = new League\OAuth2\Client\Grant\RefreshToken();
$token = $provider->getAccessToken($grant, ['refresh_token' => $refreshToken]);

// Use this to interact with an API on the users behalf
echo "Token: ". $token->getToken()."";

// Use this to get a new access token if the old one expires
echo  "Refresh Token: ".$token->getRefreshToken()."";

// Number of seconds until the access token will expire, and need refreshing
echo "Expires:" .$token->getExpires()."";
```

Testing
-------

[](#testing)

```
$ ./vendor/bin/phpunit
```

Contributing
------------

[](#contributing)

Credits
-------

[](#credits)

- [Ravishanker Kusuma](https://github.com/hayageek/)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](https://github.com/hayageek/oauth2-yahoo/blob/master/LICENSE) for more information.

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity42

Moderate usage in the ecosystem

Community20

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~162 days

Recently: every ~283 days

Total

8

Last Release

2758d ago

Major Versions

1.0.3 → 2.0.02015-09-23

### Community

Maintainers

![](https://www.gravatar.com/avatar/c2f6dcdf37eee0a2d1d57fcb667221897ee08968934db6ec99f3097c300a3660?d=identicon)[hayageek](/maintainers/hayageek)

---

Top Contributors

[![hayageek](https://avatars.githubusercontent.com/u/2642670?v=4)](https://github.com/hayageek "hayageek (5 commits)")[![timothyasp](https://avatars.githubusercontent.com/u/707699?v=4)](https://github.com/timothyasp "timothyasp (5 commits)")[![hialan](https://avatars.githubusercontent.com/u/641364?v=4)](https://github.com/hialan "hialan (1 commits)")

---

Tags

clientAuthenticationoauthoauth2authorizationyahoo

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/hayageek-oauth2-yahoo/health.svg)

```
[![Health](https://phpackages.com/badges/hayageek-oauth2-yahoo/health.svg)](https://phpackages.com/packages/hayageek-oauth2-yahoo)
```

###  Alternatives

[league/oauth2-google

Google OAuth 2.0 Client Provider for The PHP League OAuth2-Client

42121.2M118](/packages/league-oauth2-google)[cakedc/oauth2-cognito

Cognito OAuth 2.0 Client Provider for The PHP League OAuth2-Client

18597.7k](/packages/cakedc-oauth2-cognito)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
