Hi there,
After configuring module getting following error , due to can not upload files. Drupal\acquia_dam\AcquiadamAuthService::refreshAccessToken():

Thanks for help

Issue fork acquia_dam-3360415

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

lRai created an issue. See original summary.

mglaman’s picture

Priority: Critical » Normal
Status: Active » Postponed (maintainer needs more info)

What is the exact error? This is just a class and method name.

capysara’s picture

I'm getting
TypeError: Drupal\acquia_dam\AcquiadamAuthService::refreshAccessToken(): Argument #1 ($refresh_token) must be of type string, null given, called in /app/docroot/modules/contrib/acquia_dam/src/Client/AcquiaDamClientFactory.php on line 175 in Drupal\acquia_dam\AcquiadamAuthService->refreshAccessToken() (line 309 of /app/docroot/modules/contrib/acquia_dam/src/AcquiadamAuthService.php)

capysara’s picture

I'm hitting that error because I'm having issues connecting today. I made a MR that checks to be sure that the user has a token. After I add that, I'm still not able to connect, but the media library modal opens and there's a message:
Something went wrong contacting Acquia DAM, the search could not be completed.

capysara’s picture

Version: 1.0.7 » 1.0.x-dev
Status: Postponed (maintainer needs more info) » Needs review
mglaman’s picture

Thanks for helping explain the error, this seems reasonable if it's a type error.

capysara’s picture

Updated the MR. Is that the right fix for this?
I also added the check to getRefreshToken and removed "?" from "?string" because it shouldn't return null.

mglaman’s picture

Assigned: Unassigned » mglaman

That looks right! Thank you for making the fix. This is in our sprint right now, so I'll review it and get it committed.

mglaman’s picture

Yep, this looks great. It fixes passing null to \Drupal\acquia_dam\AcquiadamAuthService::refreshAccessToken and removes null|string from those two methods.

But now I'm concerned that the OAuth refresh middleware is running when it isn't supposed to, and that's why we saw this bug.

mglaman’s picture

The error lies here:

            if (!$value instanceof ResponseInterface) {
              return $value;
            }
            if ($value->getStatusCode() !== 401) {
              return $value;
            }

We can get a 401 unauthorized request before the site is configured. The code doesn't check auth_type. It assumes a refresh token should be used on 401.

  • mglaman authored 702b4cdd on 1.0.x
    Issue #3360415 by capysara: Drupal\acquia_dam\AcquiadamAuthService::...
mglaman’s picture

Assigned: mglaman » Unassigned
Status: Needs review » Fixed

Merged! We'll have a release soon with the fix. Thanks @capysara.

Status: Fixed » Closed (fixed)

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