• Failed to get data. Error:
    Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.

    Photonics loaded Google Photos fine on my site until I updated the plugin recently. I reconfigured from scratch following each steps you’ve provided, including the Google API management, client id, and secret retrieval & then inclusion on WordPress side.

    On the WordPress side, the first step in ‘Google Photos’ authentication works but when I try to obtain the token, the page shows the loading animation indefinitely without results.

    Then I followed each step you’ve provided as a workaround for authentication issues. I did everything outlined there including oauthplayground authorization, refresh token generation, & its inclusion along with client id and secret on the WordPress side. However, the page on my site set (before when everything worked) to show Google Photos albums with photonic now shows the aforementioned error.

    And when I try to add a new Google Photos with Photonic, it shows the error: No data returned. Error code 401.

    On my server-side, wp-admin/admin.php is password protected (Photonics used to work with this setup before). I have no other plugins of type – caching, security, or otherwise, that is enabled except Photonic.

    • This topic was modified 4 years, 10 months ago by Ale.
Viewing 15 replies - 1 through 15 (of 25 total)
  • Plugin Author Sayontan Sinha

    (@sayontan)

    What happens if you switch to the last working version in your case, 2.34? That was released in late March I think. Are you still seeing the error with it?

    Plugin Author Sayontan Sinha

    (@sayontan)

    If you are unsure of how to download an older version you can do so from herefrom herefrom here, under the section “Previous versions”.

    From a timeline point of view, 2.32-2.34 were released in late March, and 2.31 is considerably older.

    If you are facing issues with older versions, there is a problem with your site. If not, please let me know.

    Plugin Author Sayontan Sinha

    (@sayontan)

    One other question, before you downgrade the version for checking: what PHP version are you on? Can you get to the a 7.x version if you are on 5.6.x? Does being on newer PHP versions resolve the issue for you?

    Thread Starter Ale

    (@bijuale)

    What happens if you switch to the last working version in your case, 2.34?…Are you still seeing the error with it?

    I downgraded it but the problem still persists.

    One other question, before you downgrade the version for checking: what PHP version are you on? Can you get to the a 7.x version if you are on 5.6.x? Does being on newer PHP versions resolve the issue for you?

    I am running PHP v7.3

    Plugin Author Sayontan Sinha

    (@sayontan)

    I downgraded it but the problem still persists.

    This would seem to indicate that there is some other problem, unrelated to the new version.

    Upon a hunch I tried something out at my end – I changed a single character of the refresh token that Google gives and saved my settings. When I saved I started getting the same error on the front-end. This leads me to think that if your refresh token becomes invalid for some reason, you might face this issue.

    Long story short – I discovered a corner case wherein it might be possible to perpetually face this error. If you uninstall the plugin from your WP dashboard (first “Deactivate”, then “Delete” – don’t delete the plugin folder) and subsequently reinstall, this should go away. The downside is that your settings will be gone. Of course, if you don’t want to go through the pain of setting up the authentication again, just copy all the keys, secrets and tokens you currently have elsewhere and copy them back upon reinstallation.

    I will put a fix in place for this in the next version, but I can give you the code change you may make to fix this, too.

    Let me know if this works.

    Thread Starter Ale

    (@bijuale)

    Long story short – I discovered a corner case wherein it might be possible to perpetually face this error. If you uninstall the plugin from your WP dashboard (first “Deactivate”, then “Delete” – don’t delete the plugin folder) and subsequently reinstall, this should go away. The downside is that your settings will be gone. Of course, if you don’t want to go through the pain of setting up the authentication again, just copy all the keys, secrets and tokens you currently have elsewhere and copy them back upon reinstallation.

    I did a fresh install, as you suggest. And manually entered the google client id, client secret, & the refresh token (generated from ‘oauthplayground’ as shown in your workaround steps). The problem still persists.

    And even after the fresh install, with regards to the attempt at regular authentication (Photonic > Authentication > Step1. Authenticate > Step2. Obtain Token), the authentication goes through with the consent, and then as I click the ‘Obtain Token’ button, the loading animation shows indefinitely.

    The problem remains as before.

    I will put a fix in place for this in the next version…

    When will you release the next version?

    …but I can give you the code change you may make to fix this, too.

    Yes, could you give me the ‘code change’?

    Plugin Author Sayontan Sinha

    (@sayontan)

    For the “Obtain Token” step you will have to follow through the workaround entirely. Once you generate the tokens on Google’s site, you can save the tokens on Photonic’s settings page.

    My point is, after storing the token you should not be seeing the 401 error on the front end.

    Thread Starter Ale

    (@bijuale)

    For the “Obtain Token” step you will have to follow through the workaround entirely. Once you generate the tokens on Google’s site, you can save the tokens on Photonic’s settings page.

    Like I’ve mentioned before (this will be the 3rd time I’m reiterating this), I already did what you’ve been suggesting and so without any result.

    My point is, after storing the token you should not be seeing the 401 error on the front end.

    I understand your point. However, the problem remains.

    Plugin Author Sayontan Sinha

    (@sayontan)

    Like I’ve mentioned before (this will be the 3rd time I’m reiterating this), I already did what you’ve been suggesting and so without any result.

    I was responding to this statement that you made in your post:

    And even after the fresh install, with regards to the attempt at regular authentication (Photonic > Authentication > Step1. Authenticate > Step2. Obtain Token), the authentication goes through with the consent, and then as I click the ‘Obtain Token’ button, the loading animation shows indefinitely.

    The “loading animation” wouldn’t have gone away after reinstalling the plugin (it goes away if your app client has undergone a full verification with Google) – you would need the workaround to bypass it. I understand now that you had employed the workaround after the obtain token step failed, but the loading animation has nothing to do with the 401 issue that you are facing.

    Since resetting the plugin did not work, I doubt if the code patch will work. In any case, to apply the code patch (I am assuming you are still on 2.34):

    1. Go to the file wp-content/plugins/photonic/extensions/Photonic_OAuth2_Processor.php, line 107. You will see this block of code:
      if (!empty($token)) {
      	if ($this->is_token_expired($token)) {
      		$token = $this->refresh_access_token($refresh_token, true);
      	}
      	else {
      		$this->refresh_token_valid = true;
      }
    2. Right after it, put in this:
      else {
      	$token = $this->refresh_access_token($refresh_token, true);
      }

      So the full block will look like this:

      if (!empty($token)) {
      	if ($this->is_token_expired($token)) {
      		$token = $this->refresh_access_token($refresh_token, true);
      	}
      	else {
      		$this->refresh_token_valid = true;
      }
      else {
      	$token = $this->refresh_access_token($refresh_token, true);
      }
    3. Save the file.

    If this doesn’t resolve the 401 error on the front-end, you will have to get in touch with your host to see if they have disabled any configuration, because after deleting the plugin from the WP dashboard and replacing it with a fresh install of the older version of the plugin, you are back at a state where you had the plugin working, so a plugin change wouldn’t have triggered the problem.

    Thread Starter Ale

    (@bijuale)

    If this doesn’t resolve the 401 error on the front-end, you will have to get in touch with your host to see if they have disabled any configuration, because after deleting the plugin from the WP dashboard and replacing it with a fresh install of the older version of the plugin, you are back at a state where you had the plugin working, so a plugin change wouldn’t have triggered the problem.

    Unfortunately, the code patch did not work.

    …you will have to get in touch with your host to see if they have disabled any configuration…

    Can you suggest to me any general or specific queries or requests I should make to my web host, relevant to diagnosing this issue on their end?

    Plugin Author Sayontan Sinha

    (@sayontan)

    Hi,
    Sorry, I had missed seeing this response.

    I believe you can check with your host to see if they made any changes with respect to HTTPS calls happening via cURL from your site outwards (not from visitors to your site, but the other way round). Also check to see if they have any way to trace outbound requests made by your site. If they do, then see if any of those requests is going out to https://photoslibrary.googleapis.com/.

    I will also release a newer version in a few hours. Try that out. While that doesn’t do anything differently from what I have suggested via the steps and code above, it will eliminate any possibility of there being an error in transcribing the code at your end.

    Hi,
    I have totally the same issue since today morning. On my site nothing has changed for 2 weeks, and it was working well even yesterday. Is it possible that Google changed something?
    I’ve done all suggested solutions above with the old version, also with the latest version, it’s still not working. I’m stuck, and it’s really bad because all my site is about the photos.

    I’ve got the same infinite animation when Obtaining Token button pressed, also I’ve made the other method to get the Refresh Token, so it’s in my Google Photos settings page under Photonic, but still not working.

    The current error message on my website where the gallery was:
    “Google Photos Refresh Token invalid. Please authenticate from Photonic → Authentication.
    Error encountered during authentication:
    cURL error 28: Connection timed out after 10001 milliseconds”

    I’m not that advanced user to check the latest suggested changes with my host respect to HTTPS calls, etc, on the panel I couldn’t find any area where I can find those that you suggested in the previous post.

    Can you please suggest any other workaround?

    Thanks,
    Attila
    PS: your Photonic plugin is really amazing

    Plugin Author Sayontan Sinha

    (@sayontan)

    Error encountered during authentication:
    cURL error 28: Connection timed out after 10001 milliseconds”

    You can modify the cURL timeout from Photonic → Settings → Generic Options → Advanced → Increase cURL timeout. You can set it to something like 30.

    I would suggest first bumping up the timeout, and not trying to reauthenticate. There is a chance that your error will resolve itself, otherwise you can go through the reauthentication process.

    Hi, again me, maybe that helps, that on the OAuth 2.0 Playground, following your instruction, and reaching Step 2 – if I press the “Exchange authorization code for tokens” button, the Request / Response has got an error:

    HTTP/1.1 400 Bad Request
    Content-length: 68
    X-xss-protection: 0
    X-content-type-options: nosniff
    Transfer-encoding: chunked
    Vary: Origin, X-Origin, Referer
    Server: scaffolding on HTTPServer2
    -content-encoding: gzip
    Cache-control: private
    Date: Fri, 22 May 2020 18:29:26 GMT
    X-frame-options: SAMEORIGIN
    Alt-svc: h3-27=”:443″; ma=2592000,h3-25=”:443″; ma=2592000,h3-T050=”:443″; ma=2592000,h3-Q050=”:443″; ma=2592000,h3-Q049=”:443″; ma=2592000,h3-Q048=”:443″; ma=2592000,h3-Q046=”:443″; ma=2592000,h3-Q043=”:443″; ma=2592000,quic=”:443″; ma=2592000; v=”46,43″
    Content-type: application/json; charset=utf-8
    {
    “error_description”: “Bad Request”,
    “error”: “invalid_grant”
    }

    Although, after this I still get a Refresh token, and an access token, but probably that can be a reason what this all not working.

    Best,
    Attila

    Hi,
    I forgot to write, that setting up 30sec was not solved the problem:

    “Google Photos Refresh Token invalid. Please authenticate from Photonic → Authentication.
    Error encountered during authentication:
    cURL error 28: Connection timed out after 30001 milliseconds”

    Best,
    Attila

Viewing 15 replies - 1 through 15 (of 25 total)
  • The topic ‘Failing to load Google Photos with 401 error. Workaround fails too.’ is closed to new replies.