diff options
author | Ross Burton <ross@linux.intel.com> | 2010-03-01 09:02:33 +0000 |
---|---|---|
committer | Ross Burton <ross@linux.intel.com> | 2010-03-09 14:36:59 -0800 |
commit | 80509128a89a2d7a4572a062f96ebae1a771d05e (patch) | |
tree | ba4da827f4153df9e8e5354c484ef12fe279b947 /rest | |
parent | 2aefbe3e090689c46ee52dc6c3506a2ae7503b5d (diff) |
Add oauth_proxy_call_parse_token_reponse to parse token responses
Diffstat (limited to 'rest')
-rw-r--r-- | rest/oauth-proxy-call.c | 23 | ||||
-rw-r--r-- | rest/oauth-proxy-call.h | 2 |
2 files changed, 25 insertions, 0 deletions
diff --git a/rest/oauth-proxy-call.c b/rest/oauth-proxy-call.c index a0a0ac4..03e19d7 100644 --- a/rest/oauth-proxy-call.c +++ b/rest/oauth-proxy-call.c @@ -257,6 +257,29 @@ oauth_proxy_call_init (OAuthProxyCall *self) { } +void +oauth_proxy_call_parse_token_reponse (OAuthProxyCall *call) +{ + OAuthProxyPrivate *priv; + GHashTable *form; + + /* TODO: sanity checks, error handling, probably return gboolean */ + + g_return_if_fail (OAUTH_IS_PROXY_CALL (call)); + + priv = PROXY_GET_PRIVATE (REST_PROXY_CALL (call)->priv->proxy); + g_assert (priv); + + form = soup_form_decode (rest_proxy_call_get_payload (REST_PROXY_CALL (call))); + + priv->token = g_strdup (g_hash_table_lookup (form, "oauth_token")); + priv->token_secret = g_strdup (g_hash_table_lookup (form, "oauth_token_secret")); + /* This header should only exist for request_token replies, but its easier just to always check it */ + priv->oauth_10a = g_hash_table_lookup (form, "oauth_callback_confirmed") != NULL; + + g_hash_table_destroy (form); +} + #if BUILD_TESTS /* Test cases from http://wiki.oauth.net/TestCases */ void diff --git a/rest/oauth-proxy-call.h b/rest/oauth-proxy-call.h index 7ccb818..556728e 100644 --- a/rest/oauth-proxy-call.h +++ b/rest/oauth-proxy-call.h @@ -62,6 +62,8 @@ typedef struct { GType oauth_proxy_call_get_type (void); +void oauth_proxy_call_parse_token_reponse (OAuthProxyCall *call); + G_END_DECLS #endif /* _OAUTH_PROXY_CALL */ |