Permalink
Browse files

teach bti how to do OAuth for custom StatusNet installations

Signed-off-by: Galen Charlton <gmcharlt@gmail.com>
  • Loading branch information...
1 parent faf1eba commit 349d201697467ce70779964b59cd12848afdd52b @gmcharlt committed Nov 25, 2011
Showing with 18 additions and 0 deletions.
  1. +18 −0 bti.c
View
18 bti.c
@@ -261,6 +261,9 @@ static const char twitter_authorize_uri[] = "http://twitter.com/oauth/autho
static const char identica_request_token_uri[] = "https://identi.ca/api/oauth/request_token?oauth_callback=oob";
static const char identica_access_token_uri[] = "https://identi.ca/api/oauth/access_token";
static const char identica_authorize_uri[] = "https://identi.ca/api/oauth/authorize?oauth_token=";
+static const char custom_request_token_uri[] = "/../oauth/request_token?oauth_callback=oob";
+static const char custom_access_token_uri[] = "/../oauth/access_token";
+static const char custom_authorize_uri[] = "/../oauth/authorize?oauth_token=";
static const char user_uri[] = "/user_timeline/";
static const char update_uri[] = "/update.xml";
@@ -458,6 +461,7 @@ static int request_access_token(struct session *session)
char *at_secret = NULL;
char *verifier = NULL;
char at_uri[90];
+ char token_uri[90];
if (!session)
return -EINVAL;
@@ -472,6 +476,14 @@ static int request_access_token(struct session *session)
identica_request_token_uri, NULL,
OA_HMAC, NULL, session->consumer_key,
session->consumer_secret, NULL, NULL);
+ else {
+ sprintf(token_uri, "%s%s",
+ session->hosturl, custom_request_token_uri);
+ request_url = oauth_sign_url2(
+ token_uri, NULL,
+ OA_HMAC, NULL, session->consumer_key,
+ session->consumer_secret, NULL, NULL);
+ }
reply = oauth_http_get(request_url, post_params);
if (request_url)
@@ -502,6 +514,12 @@ static int request_access_token(struct session *session)
verifier = session->readline(NULL);
sprintf(at_uri, "%s?oauth_verifier=%s",
identica_access_token_uri, verifier);
+ } else {
+ fprintf(stdout, "%s%s%s\nPIN: ",
+ session->hosturl, custom_authorize_uri, at_key);
+ verifier = session->readline(NULL);
+ sprintf(at_uri, "%s%s?oauth_verifier=%s",
+ session->hosturl, custom_access_token_uri, verifier);
}
request_url = oauth_sign_url2(at_uri, NULL, OA_HMAC, NULL,
session->consumer_key,

0 comments on commit 349d201

Please sign in to comment.