samwilson / phpflickr

A PHP wrapper for the Flickr API, including OAuth.
https://packagist.org/packages/samwilson/phpflickr
GNU General Public License v2.0
39 stars 15 forks source link

delete returns oauth_problem=verifier_invalid #58

Open paulgodard opened 1 year ago

paulgodard commented 1 year ago

Hi Thank you for maintaining this class... I am new to it but making progress everyday!

I successfully implement the oAuth to get an access token & secret based on the example provided (get_auth_token.php). I can get private photos, so it is working.

I need to delete media at Flickr. That returns an error : Unable to decode Flickr response to flickr.photos.delete request: oauth_problem=verifier_invalid. BTW, I had a similar error when trying to use getRecent. I am on Laravel.

Here is my code...

$accessToken = "xxx";
$accessTokenSecret = "xxx";

$token = new \OAuth\OAuth1\Token\StdOAuth1Token();
$token->setAccessToken($accessToken);
$token->setAccessTokenSecret($accessTokenSecret);
$storage = new \OAuth\Common\Storage\Memory();
$storage->storeAccessToken('Flickr', $token);

$phpFlickr = new \Samwilson\PhpFlickr\PhpFlickr(['flickrKey'],['flickrSecret']);

$phpFlickr->setOauthStorage($storage);

$result = $phpFlickr->photos()->delete($id);
samwilson commented 1 year ago

I'm glad it's useful!

Did you do the initial auth request (when getting the request token) with delete permission?

Or, there does seem to be occasions when Flickr will revoke API keys — I've seen that happen on accounts that I've used for testing sometimes, and it's only when I try to re-authenticate that I find that they won't. That's probably less likely if you're using your own account though.

samwilson commented 1 year ago

Oh! Another thing that's possible: check your computer time, if it's drifted too far, then the oauth signature can fail.

paulgodard commented 1 year ago

Hi again Screenshot 2023-03-03 at 10 54 27

I used your sample that generates the following url (with the delete at the end). Is that correct? https://api.flickr.com/services/oauth/authorize?oauth_token=72157720874169042-8917c979860f976c&perms=delete

Then I click on it, there is no further options then authorizing (see attached).

Is there a setting at Flickr that forbid to delete media?

I then copy the 2 variables into the script above.

I did it several times, no change... always the same "verifier_invalid".

I need to delete many images on my account... so I need this script to work...

BTW, I checked the clock. My computer was right but Laravel was not set to UTC+2. After correcting that same issue.

I hope you will find a solution... I need to delete so many files!

BTW, how often does the authorization needs to be done? The script often asks me to re-authenticate, almost every morning... is that normal? Is it because I am running that script from my local development server which ip might change often?

Maybe the delete does not work because I run that script from my local server? Is that possible?