Hello, I tried to install and use oauth2_server on a fresh Drupal 8.3.5. The website is always reporting that "The OAuth2 server library is required for the OAuth2 module to function. Download the library using composer, downoad it from GitHub or use composer manager."

I tried to install oauth2-server-php library under /libraries and /sites/default/libraries (just in case Drupal catches it there) with Composer, Git and manually, but still, the site cannot detect it.

The Apache server log reports "PHP Fatal error: Interface 'OAuth2\\OpenID\\Storage\\AuthorizationCodeInterface' not found in /var/www/html/collabo.quebec/modules/oauth2_server/src/OAuth2StorageInterface.php on line 18".

After several hours of trial and error of trying to figure out how to get the Drupal site to detect this oauth2_server dependency, I am turning to this issue system to get help.

I face the same problem as this StackExchange question : https://drupal.stackexchange.com/questions/238764/error-oauth2-server-li...

Thanks in advance for any help. I am stuck!

CommentFileSizeAuthor
#7 2897289-07.patch544 bytesdevad
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

christian.perreault created an issue. See original summary.

bojanz’s picture

Only thing I can say is that Drupal definitely doesn't look for PHP code in /libraries and /sites/default/libraries.
Your only option is to composer require the library from the site root.

christian.perreault’s picture

Thanks @bojanz, your remark helped move forward. I am new to Drupal 8 development (I did some on Drupal 7) and I was not familiar with some new procedures. I guess the project will provide some document for its Drupal 8 edition when it will come to production stage.

So I could fix it by adding the two oauth2-server-php Composer dependencies in the "composer.json" file at the root of the Drupal folder, which are currently:

"require": {
        "bshaffer/oauth2-server-php": "~1.7",
        "bshaffer/oauth2-server-httpfoundation-bridge": "~1.1"
    }

Then I finished with "composer install".
Many thanks again!

sanduhrs’s picture

Status: Active » Closed (works as designed)

composer require drupal/oauth2_server will install the libraries automatically.

srsoftware’s picture

I ran into the same issue, with the difference, that i can not run composer on the server I'm working on. I only have file (and db) access. Thus, I still need to find out, where i have to place the libraries to make Drupal 8 recignize them.

This worked seemlessly in D7, but seems to be broken in D8.
I already tried the following locations to checkout oauth2-server-php:

/libraries
/sites/all/libraries

No success so far.

m.attar’s picture

Solve problem by Ludwig is Composer alternative

1.First of all uninstall module oauth2_server if you cannot reach the uninstall page go to modules files and comments the code in. yml files routes.yml, services.yml then you can reach reach the uninstall page and uninstall it, after that decomments all codes in files .yml.

2. Install module ludwig in order to install dependencies using Drupal Interface

3.Create file named ludwig.json in the root of the module oauth2_server then append the following code on it.

{
    "require": {
        "bshaffer/oauth2-server-php": {
            "version": "v1.7.1",
            "url": "https://github.com/bshaffer/oauth2-server-php/archive/refs/tags/v1.7.1.zip"
        },
        "bshaffer/oauth2-server-httpfoundation-bridge": {
            "version": "v1.1",
            "url": "https://github.com/bshaffer/oauth2-server-httpfoundation-bridge/archive/refs/tags/v1.1.zip"
        }
    }
}

4. Go to admin/reports/packages the above packages will appear so click on Download and unpack missing packages.

5. Now install module oauth2_server

That it!

devad’s picture

Title: The OAuth2 server library not detected » OAuth2 Server - Add Ludwig integration
Version: 8.x-1.x-dev » 2.0.x-dev
Component: Documentation » Code
Category: Support request » Feature request
Status: Closed (works as designed) » Needs review
FileSize
544 bytes

Let's open this issue again, move it to 2.x branch and convert issue title into an official Ludwig integration request for project maintainers.

Adding Ludwig integration is modern D8/9 way to solve all current and future "How can I use this module without Composer" issues.

Both required libraries are standard PSR-0 type, so adding a simple ludwig.json file is enough in this case. For maintenance, keeping ludwig.json file in sync with composer.json in future tagged versions is all what is needed.

Thank you @m.attar for initial ludwig.json file. I have updated the library versions, made download URLs a bit shorter, and made a working patch for 2.x branch.

Patch attached. Please review.

The same patch can be applied to both 2.x and 1.x branches... if the maintainer decide to add Ludwig integration to both.

There is a FAQ section inside documentation of the Ludwig module which has answers to the most of the questions which developers/maintainers of the contrib modules could ask:

Ludwig integration developer's guide and FAQ

If you have some additional questions before eventual Ludwig integration commit... please let me know here.

  • sanduhrs committed 280aa1d on 2.0.x authored by devad
    Issue #2897289 by devad, sanduhrs: OAuth2 Server - Add Ludwig...

  • sanduhrs committed 4bafe6b on 8.x-1.x authored by devad
    Issue #2897289 by devad, sanduhrs: OAuth2 Server - Add Ludwig...
sanduhrs’s picture

Status: Needs review » Fixed

Thanks for the patch.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.