The original Flickr Authentication has been deprecated in favor of OAuth. The example flickr_oauth_authentication.pl should be used in favor of this one. However, this script uses the deprecated-- but seemingly still alive-- Flickr authentication to go from having just the api_key and api_secret to an authenticated token.
./flickr_flickr_authentication.pl \ --api_key="24680beef13579feed987654321ddcc6" \ --api_secret="de0cafe4feed0242" \ [ --perms={read,write,delete} \] [ --config_out="/path/to/a/writable/config.st" ] [ --help ] [ --man ]
If not specified, perms defaults to read.
--key and --api_key are synonymous and --secret and --api_secret are also synonymous.
The script will produce a url for you to enter into a browser then prompt you to press [ENTER] once you have authenticated on Flickr.
It then does a Data::Dumper dump of the parameter keys and values which can be recorded for future use. If you want to make it more complete, you could modify the script to format and dump the information into a config file of some type. Alternatively, you can use the --config_out to specify a filename that the API can use to save itself into using the storable format.
Following the flow laid out in https://www.flickr.com/services/api/auth.howto.desktop.html more or less.
Out of scope for this particular script. We are assuming you have already obtained and configured youe api_key.
The script takes the api_key and api_secret and creates a Flickr::API object. It then calls the flickr.auth.getFrob method.
my $api = Flickr::API->new($cli_args); my $rsp = $api->execute_method("flickr.auth.getFrob");
The script now calls the request_auth_uri method with the optional perms parameter. The Flickr::API returns a uri which (in this case) is cut from the terminal and pasted into a browser.
my $request4 = $api->request_auth_uri($perms, $frob); print "\n\nYou now need to open: \n\n$request4\n\nin a browser.\n ";
Assuming all is well with the frob and request_auth_uri Flickr will open a webpage to allow you to authenticate the application identified by the api_key to have the requested perms.
This is you, granting permission to the application.
The script takes the frob and exchanges it for a token.
my $request5 = $api->flickr_access_token($frob);
Flickr will return a token if all has gone well. This is stashed in the Flickr::API object.
How you save the access information is outside the scope of this example. However, the export_config method can be used to retrieve the flickr parameters from the Flickr::API object.
my %fconfig = $api->export_config(); print Dumper(\%fconfig);
Louis B. Moore <lbmoore at cpan.org>
Copyright 2016, Louis B. Moore
This program is released under the Artistic License 2.0 by The Perl Foundation.
To install Flickr::API, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Flickr::API
CPAN shell
perl -MCPAN -e shell install Flickr::API
For more information on module installation, please visit the detailed CPAN module installation guide.