PHPackages                             webiik/oauth1client - 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. webiik/oauth1client

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

webiik/oauth1client
===================

The OAuth1Client allows you to connect to any OAuth1 server.

1.1(6y ago)071MITPHPPHP &gt;=7.2

Since Feb 28Pushed 6y ago1 watchersCompare

[ Source](https://github.com/webiik/oauth1-client)[ Packagist](https://packagist.org/packages/webiik/oauth1client)[ Docs](https://www.webiik.com)[ RSS](/packages/webiik-oauth1client/feed)WikiDiscussions master Synced 2mo ago

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

[![](https://camo.githubusercontent.com/a397347ee4fb199934fee6354504f4702b89f5c22f0ce0ba94c5ff691cde545c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f77656269696b2f77656269696b2e737667)](https://camo.githubusercontent.com/a397347ee4fb199934fee6354504f4702b89f5c22f0ce0ba94c5ff691cde545c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f77656269696b2f77656269696b2e737667)[![](https://camo.githubusercontent.com/9063c8611554aba946080355a077ff49c13af18ec286c9e8cd99c8aea668207c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f646570656e64656e636965732d322d627269676874677265656e2e737667)](https://camo.githubusercontent.com/9063c8611554aba946080355a077ff49c13af18ec286c9e8cd99c8aea668207c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f646570656e64656e636965732d322d627269676874677265656e2e737667)

OAuth1Client
============

[](#oauth1client)

The OAuth1Client allows you to connect to any OAuth1 server. Just follow the procedure described in the example below.

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

[](#installation)

```
composer require webiik/oauth1client
```

Example
-------

[](#example)

```
// Twitter Example

// Prepare dependencies
$chc = new \Webiik\CurlHttpClient\CurlHttpClient();
$token = new \Webiik\Token\Token();

// Instantiate OAuth1 client
$oAuth1Client = new \Webiik\OAuth1Client\OAuth1Client($chc, $token);

// Set your callback URL
// OAuth1 server redirects users to this URL, after user verification
$oAuth1Client->setCallbackUrl('https://127.0.0.1/webiik/');

// Set OAuth1 server endpoints
$oAuth1Client->setAuthorizeUrl('https://api.twitter.com/oauth/authenticate');
$oAuth1Client->setRequestTokenUrl('https://api.twitter.com/oauth/request_token');
$oAuth1Client->setAccessTokenUrl('https://api.twitter.com/oauth/access_token');

// Set OAuth1 server access credentials (create yours at https://developer.twitter.com/en/apps)
$oAuth1Client->setConsumerKey('your-api-key');
$oAuth1Client->setConsumerSecret('your-api-secret');

// Make API calls...
// Notice: It's a good idea to separate below steps to individual routes.

if (!isset($_GET['oauth_verifier'])) {
    // 1. Prepare Twitter login link
    echo 'Authorize with Twitter';
}

if (isset($_GET['oauth_verifier'])) {
    // 2. Verify oauth_token
    $accessToken = $oAuth1Client->getAccessToken();
}

if (isset($accessToken, $accessToken['oauth_token'], $accessToken['oauth_token_sercret'])) {
    // 3. oauth_token is valid, user is authorized by Twitter
    // Access protected resources...
    $urlParameters = [
        'skip_status' => 'true',
    ];
    $res = $oAuth1Client->get('https://api.twitter.com/1.1/account/verify_credentials.json', $accessToken['oauth_token'], $accessToken['oauth_token_secret'], $urlParameters);
    header('Content-Type: application/json');
    echo $res;
}
```

Configuration
-------------

[](#configuration)

Before you can connect to any OAuth1 server, you have to properly configure access credentials and endpoints.

### setConsumerKey

[](#setconsumerkey)

```
setConsumerKey(string $key): void
```

**setConsumerKey()** sets consumer key.

```
$oAuth1Client->setConsumerKey('your-api-key');
```

### setConsumerSecret

[](#setconsumersecret)

```
setConsumerSecret(string $secret): void
```

**setConsumerSecret()** sets consumer secret.

```
$oAuth1Client->setConsumerSecret('your-api-secret');
```

### setSignatureSecret

[](#setsignaturesecret)

```
setSignatureSecret(string $secret): void
```

**setSignatureSecret()** sets signature secret. Usually it't optional or not required.

```
$oAuth1Client->setSignatureSecret('your-api-signature-secret');
```

### setRequestTokenUrl

[](#setrequesttokenurl)

```
setRequestTokenUrl(string $url): void
```

**setRequestTokenUrl()** sets URL to obtain a request token.

```
$oAuth1Client->setRequestTokenUrl('https://api.twitter.com/oauth/request_token');
```

### setAuthorizeUrl

[](#setauthorizeurl)

```
setAuthorizeUrl(string $url): void
```

**setAuthorizeUrl()** sets URL to authorize a request token by user at OAuth1 server.

```
$oAuth1Client->setAuthorizeUrl('https://api.twitter.com/oauth/authenticate');
```

### setCallbackUrl

[](#setcallbackurl)

```
setCallbackUrl(string $url): void
```

**setCallbackUrl()** sets URL to redirect a user after authorization.

```
$oAuth1Client->setCallbackUrl('https://127.0.0.1/webiik/');
```

### setAccessTokenUrl

[](#setaccesstokenurl)

```
setAccessTokenUrl(string $url): void
```

**setAccessTokenUrl()** sets URL to obtain a access token.

```
$oAuth1Client->setAccessTokenUrl('https://api.twitter.com/oauth/access_token');
```

Login
-----

[](#login)

### getAuthorizeUrl

[](#getauthorizeurl)

```
getAuthorizeUrl($requestToken): string
```

**getAuthorizeUrl()** makes HTTP POST request to a URL set by [setRequestTokenUrl()](#setrequesttokenurl) and prepares authorized link to a URL set by [setAuthorizeUrl()](#setauthorizeurl).

```
$link = $oAuth1Client->getAuthorizeUrl();
```

Authorization
-------------

[](#authorization)

### getAccessToken

[](#getaccesstoken)

```
getAccessToken()
```

**getAccessToken()** makes HTTP POST request to URL set by [setAccessTokenUrl()](#setaccesstokenurl) and returns an array with 'oauth\_token' on success and a string with cURL error message on error.

```
$accessToken = $oAuth1Client->getAccessToken();
```

API Access
----------

[](#api-access)

### get

[](#get)

```
get(string $url, string $oauth_token, string $oauth_token_secret, array $params = []): string
```

**get()** makes authorized HTTP GET request to OAuth1 API endpoint.

```
$urlParameters = [
    'skip_status' => 'true',
];
$response = $oAuth1Client->get('https://api.twitter.com/1.1/account/verify_credentials.json', $accessToken['oauth_token'], $accessToken['oauth_token_secret'], $urlParameters);
```

### post

[](#post)

```
post(string $url, string $oauth_token, string $oauth_token_secret, array $params = [], array $postData = []): string
```

**post()** makes authorized HTTP POST request to OAuth1 API endpoint.

```
$urlParameters = [
    'include_entities' => 'true',
];
$postData = [
    'status' => 'Hello Ladies + Gentlemen, a signed OAuth request!',
];
$response = $oAuth1Client->post('https://api.twitter.com/1.1/statuses/update.json', $accessToken['oauth_token'], $accessToken['oauth_token_secret'], $urlParameters, $postData);
```

Resources
---------

[](#resources)

- [Webiik framework](https://github.com/webiik/webiik)
- [Report issue](https://github.com/webiik/components/issues)

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~160 days

Total

2

Last Release

2467d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1226362d003d186b45e7dfa44489c36af37196c6a1b476206700eaf4e9c96a5a?d=identicon)[Jiri Mihal](/maintainers/Jiri%20Mihal)

---

Top Contributors

[![Jiri-Mihal](https://avatars.githubusercontent.com/u/10408123?v=4)](https://github.com/Jiri-Mihal "Jiri-Mihal (246 commits)")

---

Tags

clientoauthoauth1

### Embed Badge

![Health badge](/badges/webiik-oauth1client/health.svg)

```
[![Health](https://phpackages.com/badges/webiik-oauth1client/health.svg)](https://phpackages.com/packages/webiik-oauth1client)
```

###  Alternatives

[happyr/linkedin-api-client

LinkedIn API client. Handles OAuth, CSRF protection. Easy to implement and extend. This is a standalone library for any composer project.

1991.6M11](/packages/happyr-linkedin-api-client)[mollie/oauth2-mollie-php

Mollie Provider for OAuth 2.0 Client

251.7M1](/packages/mollie-oauth2-mollie-php)

PHPackages © 2026

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