PHPackages                             kompas/oauth2-client - 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. kompas/oauth2-client

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

kompas/oauth2-client
====================

OAuth 2.0 Client Library

0.3(12y ago)01171MITPHPPHP &gt;=5.3.0

Since Mar 25Pushed 11y ago1 watchersCompare

[ Source](https://github.com/kompascom/oauth2-client)[ Packagist](https://packagist.org/packages/kompas/oauth2-client)[ Docs](https://github.com/kompascom/oauth2-client)[ RSS](/packages/kompas-oauth2-client/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (3)Versions (4)Used By (0)

OAuth 2.0 Client Library
========================

[](#oauth-20-client-library)

[![Build Status](https://camo.githubusercontent.com/ba0a26192ee88fde77e7df246cc12775bd7e42d15877fcaa18ba472b8d33d765/68747470733a2f2f7472617669732d63692e6f72672f7068702d6c6f65702f6f61757468322d636c69656e742e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/php-loep/oauth2-client)[![Total Downloads](https://camo.githubusercontent.com/24d03ca5af902ee3346bb678ba3bc85512db7375977e7709b874357759bbb4ad/68747470733a2f2f706f7365722e707567782e6f72672f6c65616775652f6f61757468322d636c69656e742f646f776e6c6f6164732e706e67)](https://packagist.org/packages/league/oauth2-client)[![Latest Stable Version](https://camo.githubusercontent.com/ce3fe6727031b439e8d4b8e06205bb03e06fe982507f2afc7eaa2a1fb957a3ff/68747470733a2f2f706f7365722e707567782e6f72672f6c65616775652f6f61757468322d636c69656e742f762f737461626c652e706e67)](https://packagist.org/packages/league/oauth2-client)

This library makes it stupidly simple to integrate your application with OAuth 2.0 identity providers. It has built in support for:

- Facebook
- Github
- Google
- Instagram
- LinkedIn
- Microsoft
- Vkontakte
- Kompas

Adding support for other providers is trivial.

The library requires PHP 5.3+ and is PSR-0 compatible.

First, you must install [composer](http://getcomposer.org/doc/00-intro.md) in your project.

Create a `composer.json` file in your project root:

```
{
    "require": {
        "kompas/oauth2-client": "0.3"
    }
}
```

Add this line to your application’s `index.php` file:

```
require 'vendor/autoload.php';
```

Usage for Kompas
----------------

[](#usage-for-kompas)

```
// composer autoload
require_once "vendor/autoload.php";

$provider = new League\OAuth2\Client\Provider\Kompas(array(
    'clientId'  =>  'XXXXXXXX',
    'clientSecret'  =>  'XXXXXXXX',
    'redirectUri'   =>  ''
));

try {

    // Try to get an access token (using the client credentials grant)
    $t = $provider->getAccessToken('client_credentials');

    try {

        $provider->setFilterBySite('nasional,megapolitan');
        $latest = $provider->getRssLatest($t);
        $response['latestFiltered'] = json_decode($latest, true); // result filtered
        $mostcommented = $provider->getRssMostCommented($t);
        $response['mostCommentedFiltered'] = json_decode($mostcommented, true); // result filtered
        $provider->setFilterBySite(); // reset filtered
        $mostpopular = $provider->getRssMostPopular($t);
        $response['mostPopularNonFiltered'] = json_decode($mostpopular, true); // result not filtered

    } catch (Exception $e) {

        // Failed to get Rss
        $response = array(
            'status' => false,
            'error' => $e->getMessage()
        );
    }

} catch (Exception $e) {

    // Failed to get access token
    $response = array(
        'status' => false,
        'error' => $e->getMessage()
    );
}

header("Content-Type: application/json");
echo json_encode($response);
```

Available Feature:

`getRssLatest(token, service, siteno, sectionid)``getRssMostCommented(token, service, siteno, sectionid)``getRssMostPopular(token, service, siteno, sectionid)``setFilterBySite(sites)` \*only in `json` format

Example:

```
$all_latest = $provider->getRssLatest(AccessToken);
$provider->setFilterBySite('nasional,megapolitan'); // (,) delimiter
$filter_latest = $provider->getRssLatest(AccessToken);
$provider->setFilterBySite(); // reset filter
$news_latest = $provider->getRssLatest(AccessToken, 'kompascom', 1, 1);
```

Kompas API Reference
--------------------

[](#kompas-api-reference)

Authorization:

Request body

- HTTP request `POST http://apis.kompas.com/oauth2/token`
- Parameters Require body parameters

    - client\_id \[Your registered client id\]
    - client\_secret \[Your registered client secret\]
    - grant\_type \[MUST value "client\_credentials"\]
- Example

    ```
    POST /oauth2/token HTTP/1.1
    Host: apis.kompas.com
    Cache-Control: no-cache
    Content-Type: application/x-www-form-urlencoded

    client_id=xxx&client_secret=xxx&grant_type=client_credentials
    ```
- Response

```
{
    "access_token": "xxx",
    "token_type": "bearer",
    "expires": 1387445831,
    "expires_in": 3600
}
```

Kompascom: latest
-----------------

[](#kompascom-latest)

Requires authorization

Request body

- HTTP request `GET http://apis.kompas.com/rss/kompascom/latest`
- Parameters Require query parameters

    - access\_token \[MUST value access token from authorization response\]

    Optional path parameters

    - siteId \[integer\]
    - sectionId \[integer\]

    Optional query parameters

    - filterBySite \[string, delimeter with comma. ex: nasional,megapolitan\]
- Example all latests

    ```
    GET /rss/kompascom/latest?access_token=xxx HTTP/1.1
    Host: apis.kompas.com
    Cache-Control: no-cache
    Content-Type: application/x-www-form-urlencoded
    ```
- Example latest with filter sites

    ```
    GET /rss/kompascom/latest?access_token=xxx&filterBySite=nasional,megapolitan HTTP/1.1
    Host: apis.kompas.com
    Cache-Control: no-cache
    Content-Type: application/x-www-form-urlencoded
    ```
- Example latest for specific site

    ```
    GET /rss/kompascom/latest/1?access_token=xxx HTTP/1.1
    Host: apis.kompas.com
    Cache-Control: no-cache
    Content-Type: application/x-www-form-urlencoded
    ```
- Example latest for specific section site

    ```
    GET /rss/kompascom/latest/1/1?access_token=xxx HTTP/1.1
    Host: apis.kompas.com
    Cache-Control: no-cache
    Content-Type: application/x-www-form-urlencoded
    ```
- Response

```
[
    {
        uid: "2013.12.13.0711189",
        channel: {
            site: "bola",
            section: ""
        },
        title: "Awal Januari, Trofi Piala Dunia Tiba di Indonesia",
        description: "Coca-Cola sebagai official sponsor of the FIFA World Cup™ ...",
        media: {
            image: {
                thumb: "http://assets.kompas.com/data/photo/2013/12/13/1458220455320155t.jpg",
                content: "http://assets.kompas.com/data/photo/2013/12/13/1458220455320155780x390.jpg"
            }
        },
        url: {
            permalink: "http://bola.kompas.com/read/2013/12/13/0711189/Awal.Januari.Trofi.Piala.Dunia.Tiba.di.Indonesia"
        },
        service: "kompascom",
        published_date: "2013-12-13 07:11:18"
    },
    ...
]
```

Kompascom: Most Commented
-------------------------

[](#kompascom-most-commented)

Requires authorization

Request body

- HTTP request `GET http://apis.kompas.com/rss/kompascom/mostcommented`
- Parameters Require query parameters

    - access\_token \[MUST value access token from authorization response\]

    Optional path parameters

    - siteId \[integer\]
    - sectionId \[integer\]

    Optional query parameters

    - filterBySite \[string, delimeter with comma. ex: nasional,megapolitan\]
- Example all of most commented

    ```
    GET /rss/kompascom/mostcommented?access_token=xxx HTTP/1.1
    Host: apis.kompas.com
    Cache-Control: no-cache
    Content-Type: application/x-www-form-urlencoded
    ```
- Example most commented with filter sites

    ```
    GET /rss/kompascom/mostcommented?access_token=xxx&filterBySite=nasional,megapolitan HTTP/1.1
    Host: apis.kompas.com
    Cache-Control: no-cache
    Content-Type: application/x-www-form-urlencoded
    ```
- Example most commented for specific site

    ```
    GET /rss/kompascom/mostcommented/1?access_token=xxx HTTP/1.1
    Host: apis.kompas.com
    Cache-Control: no-cache
    Content-Type: application/x-www-form-urlencoded
    ```
- Example most commented for specific section site

    ```
    GET /rss/kompascom/mostcommented/1/1?access_token=xxx HTTP/1.1
    Host: apis.kompas.com
    Cache-Control: no-cache
    Content-Type: application/x-www-form-urlencoded
    ```
- Response

```
[
    {
        uid: "2013.12.13.0711189",
        channel: {
            site: "bola",
            section: ""
        },
        title: "Awal Januari, Trofi Piala Dunia Tiba di Indonesia",
        description: "Coca-Cola sebagai official sponsor of the FIFA World Cup™ ...",
        media: {
            image: {
                thumb: "http://assets.kompas.com/data/photo/2013/12/13/1458220455320155t.jpg",
                content: "http://assets.kompas.com/data/photo/2013/12/13/1458220455320155780x390.jpg"
            }
        },
        url: {
            permalink: "http://bola.kompas.com/read/2013/12/13/0711189/Awal.Januari.Trofi.Piala.Dunia.Tiba.di.Indonesia"
        },
        service: "kompascom",
        published_date: "2013-12-13 07:11:18",
        statistics: {
            comment_count: 279
        }
    },
    ...
]
```

Kompascom: Most Popular
-----------------------

[](#kompascom-most-popular)

Requires authorization

Request body

- HTTP request `GET http://apis.kompas.com/rss/kompascom/mostpopular`
- Parameters Require query parameters

    - access\_token \[MUST value access token from authorization response\]

    Optional path parameters

    - siteId \[integer\]
    - sectionId \[integer\]

    Optional query parameters

    - filterBySite \[string, delimeter with comma. ex: nasional,megapolitan\]
- Example all of most popular

    ```
    GET /rss/kompascom/mostpopular?access_token=xxx HTTP/1.1
    Host: apis.kompas.com
    Cache-Control: no-cache
    Content-Type: application/x-www-form-urlencoded
    ```
- Example most popular with filter sites

    ```
    GET /rss/kompascom/mostpopular?access_token=xxx&filterBySite=nasional,megapolitan HTTP/1.1
    Host: apis.kompas.com
    Cache-Control: no-cache
    Content-Type: application/x-www-form-urlencoded
    ```
- Example most popular for specific site

    ```
    GET /rss/kompascom/mostpopular/1?access_token=xxx HTTP/1.1
    Host: apis.kompas.com
    Cache-Control: no-cache
    Content-Type: application/x-www-form-urlencoded
    ```
- Example most popular for specific section site

    ```
    GET /rss/kompascom/mostpopular/1/1?access_token=xxx HTTP/1.1
    Host: apis.kompas.com
    Cache-Control: no-cache
    Content-Type: application/x-www-form-urlencoded
    ```
- Response

```
[
    {
        uid: "2013.12.13.0711189",
        channel: {
            site: "bola",
            section: ""
        },
        title: "Awal Januari, Trofi Piala Dunia Tiba di Indonesia",
        description: "Coca-Cola sebagai official sponsor of the FIFA World Cup™ ...",
        media: {
            image: {
                thumb: "http://assets.kompas.com/data/photo/2013/12/13/1458220455320155t.jpg",
                content: "http://assets.kompas.com/data/photo/2013/12/13/1458220455320155780x390.jpg"
            }
        },
        url: {
            permalink: "http://bola.kompas.com/read/2013/12/13/0711189/Awal.Januari.Trofi.Piala.Dunia.Tiba.di.Indonesia"
        },
        service: "kompascom",
        published_date: "2013-12-13 07:11:18",
        statistics: {
            read_count: 279
        }
    },
    ...
]
```

License
-------

[](#license)

The MIT License (MIT). Please see [License File](https://github.com/php-loep/:package_name/blob/master/LICENSE) for more information.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

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

Total

2

Last Release

4484d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3264535342f6dd2bacce6425cb96c32d6113e25e3adac91a11660be332e764eb?d=identicon)[fahmiardi](/maintainers/fahmiardi)

---

Top Contributors

[![alexbilbie](https://avatars.githubusercontent.com/u/77991?v=4)](https://github.com/alexbilbie "alexbilbie (46 commits)")[![fahmiardi](https://avatars.githubusercontent.com/u/1201482?v=4)](https://github.com/fahmiardi "fahmiardi (25 commits)")[![bencorlett](https://avatars.githubusercontent.com/u/181919?v=4)](https://github.com/bencorlett "bencorlett (9 commits)")[![msurguy](https://avatars.githubusercontent.com/u/585833?v=4)](https://github.com/msurguy "msurguy (6 commits)")[![dhrrgn](https://avatars.githubusercontent.com/u/149921?v=4)](https://github.com/dhrrgn "dhrrgn (3 commits)")[![tomsobpl](https://avatars.githubusercontent.com/u/124267?v=4)](https://github.com/tomsobpl "tomsobpl (1 commits)")[![bitinn](https://avatars.githubusercontent.com/u/1484279?v=4)](https://github.com/bitinn "bitinn (1 commits)")[![kompascom](https://avatars.githubusercontent.com/u/5997587?v=4)](https://github.com/kompascom "kompascom (1 commits)")[![PavloPoliakov](https://avatars.githubusercontent.com/u/839290?v=4)](https://github.com/PavloPoliakov "PavloPoliakov (1 commits)")[![tfountain](https://avatars.githubusercontent.com/u/387569?v=4)](https://github.com/tfountain "tfountain (1 commits)")

---

Tags

AuthenticationSSOidentityoauthoauth2authorizationidpsingle sign on

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/kompas-oauth2-client/health.svg)

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

###  Alternatives

[adam-paterson/oauth2-slack

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

22694.8k5](/packages/adam-paterson-oauth2-slack)

PHPackages © 2026

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