# Fatal error: Uncaught Error: Class "Patreon\\OAuth" not found

**URL:** <https://www.patreondevelopers.com/t/fatal-error-uncaught-error-class-patreon-oauth-not-found/4731>\
**Category:** Friendly Help\
**Created:** [September 11, 2021, 10:05am UTC](https://www.patreondevelopers.com/t/fatal-error-uncaught-error-class-patreon-oauth-not-found/4731 "2021-09-11T10:05:09Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alex\_Human](https://yyz2.discourse-cdn.com/flex036/user_avatar/www.patreondevelopers.com/alex_human/32/1796_2.png) [@Alex\_Human](https://www.patreondevelopers.com/u/Alex_Human)\
**Post date:** [September 11, 2021, 10:05am UTC](https://www.patreondevelopers.com/t/fatal-error-uncaught-error-class-patreon-oauth-not-found/4731/1 "2021-09-11T10:05:09Z")

</div>

I have a problem with the OAuth class. I did everything as shown here [patreon/patreon - Packagist](https://packagist.org/packages/patreon/patreon) but I still get this error.

The library is installed correctly. In the folder vendor/patreon/patreon/src/OAuth.php the file is available

use Patreon\API; //works  
use Patreon\OAuth; //does not work

my composer.json file  
{  
“require”: {  
“patreon/patreon”: “^1.0”  
}  
}

Maybe someone had such a problem? I didn’t find any similar questions

---

<div class="post-metadata">

**Author:** ![Zanaras](https://yyz2.discourse-cdn.com/flex036/user_avatar/www.patreondevelopers.com/zanaras/32/1792_2.png) [@Zanaras](https://www.patreondevelopers.com/u/Zanaras)\
**Post date:** [September 11, 2021, 8:13pm UTC](https://www.patreondevelopers.com/t/fatal-error-uncaught-error-class-patreon-oauth-not-found/4731/2 "2021-09-11T20:13:02Z")

</div>

That’s… very strange. Have you tired reinstalling the package?

Alternatively, you could try restarting the web server/service, as it could be a, admittedly strange, caching issue.

If neither of those work, would you mind sharing more of the code you’re using? Without seeing it I’m not sure how much more I can help past this.

---

<div class="post-metadata">

**Author:** ![Alex\_Human](https://yyz2.discourse-cdn.com/flex036/user_avatar/www.patreondevelopers.com/alex_human/32/1796_2.png) [@Alex\_Human](https://www.patreondevelopers.com/u/Alex_Human)\
**Post date:** [September 11, 2021, 8:34pm UTC](https://www.patreondevelopers.com/t/fatal-error-uncaught-error-class-patreon-oauth-not-found/4731/3 "2021-09-11T20:34:16Z")

</div>

Thank you for any help.  
I can’t restart the server because it is hosting.

Here I form a link

```auto
$client_id = '123';
$redirect_uri = 'https://mysite/app/donate/api/patreon';
$patreounUrl = 'https://www.patreon.com/oauth2/authorize?response_type=code&client_id=' . $client_id . '&redirect_uri=' . urlencode($redirect_uri) .'&state='.$user['user_id'];

```

Next, I accept the data on $redirect\_uri = ‘[https://mysite/app/donate/api/patreon](https://mysite/app/donate/api/patreon)’;

```auto
// Require Composer's autoloader.
require_once ''.$_SERVER['DOCUMENT_ROOT'].'/vendor/autoload.php';
 
use Patreon\API;
use Patreon\OAuth; //error here

if ($_GET['code'] != '' && $_GET['state'] != '' ) {
    
    $user = htmlspecialchars($_GET['state']);
    $code = htmlspecialchars($_GET['code']);

    $client_id = '123';
    $client_secret = '123';
    $redirect_uri = 'https://mysite/app/donate/api/patreon';

    $oauth_client = new OAuth($client_id, $client_secret); //error here

    $tokens = $oauth_client->get_tokens($code, $redirect_uri);
    $access_token = $tokens['access_token'];
    $refresh_token = $tokens['refresh_token'];

    if ($access_token != '' && $refresh_token != '') {
        echo 'tokens received';
        //actions with the database
    }

}

    $api_client = new API($access_token);

    //$api_client->api_return_format = 'object';
    $patron_response = $api_client->fetch_user();

    print_r($patron_response);

```

---

<div class="post-metadata">

**Author:** ![Alex\_Human](https://yyz2.discourse-cdn.com/flex036/user_avatar/www.patreondevelopers.com/alex_human/32/1796_2.png) [@Alex\_Human](https://www.patreondevelopers.com/u/Alex_Human)\
**Post date:** [September 12, 2021, 1:21am UTC](https://www.patreondevelopers.com/t/fatal-error-uncaught-error-class-patreon-oauth-not-found/4731/4 "2021-09-12T01:21:31Z")

</div>

The problem was solved by update composer to the latest version.

---

<div class="post-metadata">

**Author:** ![codebard](https://yyz2.discourse-cdn.com/flex036/user_avatar/www.patreondevelopers.com/codebard/32/14_2.png) [@codebard](https://www.patreondevelopers.com/u/codebard)\
**Post date:** [September 14, 2021, 3:56pm UTC](https://www.patreondevelopers.com/t/fatal-error-uncaught-error-class-patreon-oauth-not-found/4731/5 "2021-09-14T15:56:26Z")

</div>

Great to hear you solved it. A better way could be to use github PHP repo for CI purposes.

> **[GitHub - Patreon/patreon-php: Interact with the Patreon API via OAuth](https://github.com/Patreon/patreon-php)**
>
> Interact with the Patreon API via OAuth. Contribute to Patreon/patreon-php development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![Zanaras](https://yyz2.discourse-cdn.com/flex036/user_avatar/www.patreondevelopers.com/zanaras/32/1792_2.png) [@Zanaras](https://www.patreondevelopers.com/u/Zanaras)\
**Post date:** [September 14, 2021, 10:48pm UTC](https://www.patreondevelopers.com/t/fatal-error-uncaught-error-class-patreon-oauth-not-found/4731/6 "2021-09-14T22:48:14Z")

</div>

Packagist is a package manager for PHP. If you follow that link he provided in the first post, you’ll see the link to the github repo you recommend on the right under details. This is where packagist lists the repo source and where packagist itself is pulling the source from. Packagist just let’s him use PHP Composer’s require and update functionality via command line to pull versions from github. There are also several other alternatives to Composer that implement similar functionality.

Very common for PHP projects.
