PHP Classes

Flickr Permissions

Recommend this page to a friend!

      PHP OAuth Library  >  PHP OAuth Library package blog  >  How to Implement PHP ...  >  All threads  >  Flickr Permissions  >  (Un) Subscribe thread alerts  
Subject:Flickr Permissions
Summary:Flickr requires perm variable to be set
Messages:6
Author:Jasper
Date:2013-03-28 11:14:33
Update:2013-03-31 07:30:38
 

  1. Flickr Permissions   Reply   Report abuse  
Picture of Jasper Jasper - 2013-03-28 11:14:33
Hi Manuel,

Thank you for these classes. Just what I was looking for. They seem to work great. However, I ran into an issue when trying to authenticate with flickr.

Apparently flickr requires the permissions to be set, otherwise the user will get the message "Oops! Flickr doesn't recognise the permission set." on flickr. I've tried setting the scope variable, but unfortunately that doesn't help. I get the same message as above.

I reckon flickr is a bit quirky in this perspective, requiring a perms variable instead of a scope variable. Hence, I've also tried to add the perms variable to the dialog_url (e.g. http://www.flickr.com/services/oauth/authorize?perms=write) but the perms variable is removed in the process and as result I got the same error message.

I hope you got an idea on how to solve this issue.

Thanks in advance for your time and effort.

Kind regards,


Jasper

  2. Re: Flickr Permissions   Reply   Report abuse  
Picture of Jasper Jasper - 2013-03-28 11:48:50 - In reply to message 1 from Jasper
Made a small mistake. Placed the dialog_url adaptation before the Initialize statement. When I change it after running initialize:

if(($success = $client->Initialize())) {
$client->dialog_url = 'http://www.flickr.com/services/oauth/authorize?perms=write';

I get the error:

Oops! There's no "oauth_token" parameter.

Which is the result of a ? instead of a & in the url:

flickr.com/services/oauth/authorize ...

(notice the ? between perms=write and oauth_token=...

I noticed that for Oauth 2.0 you have code who deals with that, hence I used that for a fix I'd like to propose:

On line 1923 of the oauth_client class replace:

$url .= '?oauth_token='.$access_token['value'];

with:

$url = str_replace('{SCOPE}', UrlEncode($this->scope), $url);
$url .= (strpos($url, '?') === false ? '?' : '&').'oauth_token='.$access_token['value'];


And on line 1618 replace:

$this->dialog_url = 'http://www.flickr.com/services/oauth/authorize';

with:

$this->dialog_url = 'http://www.flickr.com/services/oauth/authorize?perms={SCOPE}';

That fixes the flickr issue.

Thanks again for these clases!

Kind regards,


Jasper

  3. Re: Flickr Permissions   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2013-03-29 08:07:50 - In reply to message 1 from Jasper
I do not think that is the way to setup the application permissions.

First make sure the callback URL is already set in your applications page pointing to your Flickr OAuth authorization script.

$api_key = 'Your application API key here';
$api_secret = 'Your application API key here';
$perms = 'delete'; // May be 'read' 'write' 'delete'
$api_sig = 'api_key'.$api_key.'perms'.$perms;
$api_sig = md5($api_secret.$api_sig);
$url = 'http://flickr.com/services/auth/?api_key='.$api_key. '&perms='.$perms. '&api_sig='.$api_sig;
echo '<a href="'.HtmlSpecialChars($url).'">Login with Flickr</a>';
// or Header('Location: '.$url);

  4. Re: Flickr Permissions   Reply   Report abuse  
Picture of Jasper Jasper - 2013-03-29 08:37:53 - In reply to message 3 from Manuel Lemos
Hi Manuel,

Thank you for your reply. I'm not sure how to go about this in the oauth procedure descibed by flickr here: http://www.flickr.com/services/api/auth.oauth.html

At "Getting the User Authorization", none of the variables apart from the perms variable you list in your example are pased on to flickr.
The example you gave looks quite like the old authentication method Flickr used (http://www.flickr.com/services/api/auth.howto.web.html)

The information for the oauth authentication does state that the permissions can be set in the authentication flow settings of the app, but the only app type you can set the permissions for is a mobile app. For a web application there is no field to set the permissions.

Kind regards,


Jasper

  5. Re: Flickr Permissions   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2013-03-29 09:12:00 - In reply to message 4 from Jasper
Sorry, you are right. I was looking at the old authentication method page, which still works.

Anyway, I realized there was a issue when concatenating parameters to dialog URLs that already have the ? character. I just fixed that issue and also allowed replacing scope values in the dialog URL for OAuth 1 servers.

So it should work now setting the permissions in the scope variable. Thanks for reporting.

  6. Re: Flickr Permissions   Reply   Report abuse  
Picture of Jasper Jasper - 2013-03-31 07:30:38 - In reply to message 5 from Manuel Lemos
No worries, thank you for making the changes to the class. And again, I really like this class! Thanks for your time and effort and for sharing it!