Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

teach bti how to do OAuth for custom StatusNet installations #20

Merged
merged 1 commit into from Nov 28, 2011
Jump to file or symbol
Failed to load files and symbols.
+18 −0
Split
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,