PHPackages                             ray/oauth-module - 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. ray/oauth-module

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

ray/oauth-module
================

OAuth module for Ray.Di

2.2.0(8y ago)41.3k1MITPHPPHP &gt;=7.0

Since Dec 27Pushed 8y ago7 watchersCompare

[ Source](https://github.com/ray-di/Ray.OAuthModule)[ Packagist](https://packagist.org/packages/ray/oauth-module)[ RSS](/packages/ray-oauth-module/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (6)Versions (7)Used By (0)

Ray.OAuthModule
===============

[](#rayoauthmodule)

[![Build Status](https://camo.githubusercontent.com/e692bbfd957e0526320cd5653306ec70ac15dab5c9ce19790a07b782a1abaae6/68747470733a2f2f7472617669732d63692e6f72672f7261792d64692f5261792e4f417574684d6f64756c652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/ray-di/Ray.OAuthModule)

[OAuth](https://github.com/kawanamiyuu/Maye.OAuthClient) Module for [Ray.Di](https://github.com/ray-di/Ray.Di)

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

[](#installation)

### Composer install

[](#composer-install)

```
$ composer require ray/oauth-module
```

### Module install

[](#module-install)

```
use Ray\Di\AbstractModule;
use Ray\OAuthModule\OAuth1Module;
use Ray\OAuthModule\OAuth1Service;

class AppModule extends AbstractModule
{
	protected function configure()
	{
		$this->install(new OAuth1Module(OAuth1Service::TWITTER, $_ENV['CONSUMER_KEY'], $_ENV['CONSUMER_SECRET'], '/oauth/callback'));
	}
}
```

### Usage

[](#usage)

Redirects to the authorization page.

```
use Ray\OAuthModule\Inject\TwitterOAuthInject;

class OAuthController
{
    use TwitterOAuthInject;

    public function redirectAction()
    {
        $this->twitterOAuth->authorize();
    }
}
```

Requests the AccessToken. This is callback process after authorization finished.

```
use Ray\OAuthModule\Inject\TwitterOAuthInject;

class OAuthController
{
    use TwitterOAuthInject;

    public function callbackAction()
    {
        if ($_GET['denied']) {
            // should be handled as error
            return 'ERROR';
        }

        // requests AccessToken
        $token = $this->twitterOAuth->requestAccessToken($_GET['oauth_token'], $_GET['oauth_verifier']);
        /** @var OAuth\OAuth1\Token\TokenInterface $token */

        // $accessToken       = $token->getAccessToken();
        // $accessTokenSecret = $token->getAccessTokenSecret();
        $userId     = $token->getExtraParams()['user_id'];
        $screenName = $token->getExtraParams()['screen_name'];

        // gets authorized user info
        $user = $this->twitterOAuth->api('get', 'users/show.json', ['user_id' => $userId]);
        $user = json_decode($user);

        $result = 'user_id : ' . $userId .'';
        $result.= 'screen_name : @' . $screenName . '';
        $result.= 'name: ' . $user->name;

        return $result;
    }
}
```

Demo
----

[](#demo)

#### OAuth1 (Twitter)

[](#oauth1-twitter)

See `docs/demo/www/oauth1_twitter.php` for detail.

```
# 1. Create and configure the Twitter App on Developer Website

# 2. Set Consumer Key and Secret in docs/demo/www/oauth1_twitter.php

# 3. Start the PHP built-in Web-Server
$ php -S localhost:8080 -t docs/demo/www

# 4. Access http://localhost:8080/oauth1_twitter.php
>
user_id: {Your User ID}
screen_name: @{your_screen_name}
name: {Your Name}
```

#### OAuth2 (Facebook)

[](#oauth2-facebook)

See `docs/demo/www/oauth2_facebook.php` for detail.

```
# 1. Create and configure the Facebook App on Developer Website

# 2. Set App ID and Secret in docs/demo/www/oauth2_facebook.php

# 3. Start the PHP built-in Web-Server
$ php -S localhost:8080 -t docs/demo/www

# 4. Access http://localhost:8080/oauth2_facebook.php
>
id: {Your ID}
name: {Your Name}
```

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 85.7% of commits — single point of failure

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 ~211 days

Recently: every ~261 days

Total

6

Last Release

3102d ago

Major Versions

1.1.1 → 2.0.02015-03-11

PHP version history (2 changes)1.1.0PHP &gt;=5.5.0

2.2.0PHP &gt;=7.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/83cb12b2e0fa43bb9ec62e161039cc7226b0077a631b62d0b25e9e6c00b46a1d?d=identicon)[kawanamiyuu](/maintainers/kawanamiyuu)

---

Top Contributors

[![kawanamiyuu](https://avatars.githubusercontent.com/u/1461463?v=4)](https://github.com/kawanamiyuu "kawanamiyuu (66 commits)")[![koriym](https://avatars.githubusercontent.com/u/529021?v=4)](https://github.com/koriym "koriym (11 commits)")

---

Tags

oauthoauth2ray-moduleoauthRay.Di

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/ray-oauth-module/health.svg)

```
[![Health](https://phpackages.com/badges/ray-oauth-module/health.svg)](https://phpackages.com/packages/ray-oauth-module)
```

###  Alternatives

[league/oauth2-server

A lightweight and powerful OAuth 2.0 authorization and resource server library with support for all the core specification grants. This library will allow you to secure your API with OAuth and allow your applications users to approve apps that want to access their data from your API.

6.6k136.0M248](/packages/league-oauth2-server)[league/oauth2-client

OAuth 2.0 Client Library

3.8k118.6M1.2k](/packages/league-oauth2-client)[league/oauth1-client

OAuth 1.0 Client Library

99698.8M106](/packages/league-oauth1-client)[knpuniversity/oauth2-client-bundle

Integration with league/oauth2-client to provide services

83416.7M61](/packages/knpuniversity-oauth2-client-bundle)[socialiteproviders/manager

Easily add new or override built-in providers in Laravel Socialite.

42442.0M544](/packages/socialiteproviders-manager)[league/oauth2-google

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

41721.2M118](/packages/league-oauth2-google)

PHPackages © 2026

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