Permalink
Browse files

Add oauth.verify command to upgrade legacy auth to OAuth

  • Loading branch information...
dajobe committed Sep 2, 2012
1 parent 34418f4 commit 4a38b181b1242a345d3220a81d7eccf2370b27d2
Showing with 33 additions and 2 deletions.
  1. +33 −2 utils/flickcurl.c
View
@@ -4991,15 +4991,42 @@ command_oauth_verify(flickcurl* fc, int argc, char *argv[])
}
fprintf(stderr,
- "%s: OAuth access token returned token '%s' secret token '%s'\n",
+ "%s: Returned OAuth token '%s' and token secret '%s'\n",
program,
flickcurl_get_oauth_token(fc),
flickcurl_get_oauth_token_secret(fc));
rc = flickcurl_config_write_ini(fc, config_path, config_section);
if(!rc)
fprintf(stdout,
- "%s: Updated configuration file %s with authentication token\n",
+ "%s: Updated configuration file %s with OAuth tokens\n",
+ program, config_path);
+
+ return 0;
+}
+
+
+static int
+command_oauth_upgrade(flickcurl* fc, int argc, char *argv[])
+{
+ int rc;
+
+ rc = flickcurl_auth_oauth_getAccessToken(fc);
+ if(rc) {
+ fprintf(stderr, "%s: Failed to upgrade to OAuth\n", program);
+ return 1;
+ }
+
+ fprintf(stderr,
+ "%s: Upgraded to OAuth token '%s' and token secret '%s'\n",
+ program,
+ flickcurl_get_oauth_token(fc),
+ flickcurl_get_oauth_token_secret(fc));
+
+ rc = flickcurl_config_write_ini(fc, config_path, config_section);
+ if(!rc)
+ fprintf(stdout,
+ "%s: Updated configuration file %s with OAuth tokens\n",
program, config_path);
return 0;
@@ -5598,6 +5625,10 @@ static flickcurl_cmd commands[] = {
"REQUEST-TOKEN REQUEST-TOKEN-SECRET VERIFIER", "Verify an OAuth request from `oauth-create'",
command_oauth_verify, 3, 3},
+ {"oauth.upgrade",
+ "", "Upgrade legacy authentication to OAuth",
+ command_oauth_upgrade, 0, 0},
+
{NULL,
NULL, NULL,
NULL, 0, 0}

0 comments on commit 4a38b18

Please sign in to comment.