summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/reference/rest/rest-sections.txt2
-rw-r--r--rest/oauth-proxy.c98
-rw-r--r--rest/oauth-proxy.h19
3 files changed, 118 insertions, 1 deletions
diff --git a/docs/reference/rest/rest-sections.txt b/docs/reference/rest/rest-sections.txt
index e71579d..bd56251 100644
--- a/docs/reference/rest/rest-sections.txt
+++ b/docs/reference/rest/rest-sections.txt
@@ -166,7 +166,9 @@ OAuthProxyAuthCallback
oauth_proxy_auth_step
oauth_proxy_auth_step_async
oauth_proxy_request_token
+oauth_proxy_request_token_async
oauth_proxy_access_token
+oauth_proxy_access_token_async
oauth_proxy_get_token
oauth_proxy_set_token
oauth_proxy_get_token_secret
diff --git a/rest/oauth-proxy.c b/rest/oauth-proxy.c
index e0594d7..fb3bd51 100644
--- a/rest/oauth-proxy.c
+++ b/rest/oauth-proxy.c
@@ -410,6 +410,55 @@ oauth_proxy_request_token (OAuthProxy *proxy,
}
/**
+ * oauth_proxy_request_token_async:
+ * @proxy: an #OAuthProxy
+ * @function: the function name to invoke
+ * @callback_uri: the callback URI
+ * @callback: a #OAuthProxyAuthCallback to invoke on completion
+ * @weak_object: #GObject to weakly reference and tie the lifecycle of the method call too
+ * @user_data: user data to pass to @callback
+ * @error: a #GError, or %NULL
+ *
+ * Perform the Request Token phase of OAuth, invoking @function (defaulting to
+ * "request_token" if @function is NULL).
+ *
+ * The value of @callback depends on whether the server supports OAuth 1.0 or
+ * 1.0a. If it only supports 1.0 then callback can be NULL. If it supports
+ * 1.0a then @callback should either be your callback URI, or "oob"
+ * (out-of-band).
+ *
+ * This method will return once the method has been queued, @callback will be
+ * invoked when it has completed.
+ *
+ * Returns: %TRUE if the method was successfully queued, or %FALSE on
+ * failure. On failure @error is set.
+ */
+gboolean
+oauth_proxy_request_token_async (OAuthProxy *proxy,
+ const char *function,
+ const char *callback_uri,
+ OAuthProxyAuthCallback callback,
+ GObject *weak_object,
+ gpointer user_data,
+ GError **error)
+{
+ RestProxyCall *call;
+ AuthData *data;
+
+ call = rest_proxy_new_call (REST_PROXY (proxy));
+ rest_proxy_call_set_function (call, function ? function : "request_token");
+
+ if (callback_uri)
+ rest_proxy_call_add_param (call, "oauth_callback", callback_uri);
+
+ data = g_slice_new0 (AuthData);
+ data->callback = callback;
+ data->user_data = user_data;
+
+ return rest_proxy_call_async (call, auth_callback, weak_object, data, error);
+}
+
+/**
* oauth_proxy_access_token:
* @proxy: an #OAuthProxy
* @function: the function name to invoke
@@ -459,6 +508,55 @@ oauth_proxy_access_token (OAuthProxy *proxy,
}
/**
+ * oauth_proxy_access_token_async:
+ * @proxy: an #OAuthProxy
+ * @function: the function name to invoke
+ * @verifier: the verifier
+ * @callback: a #OAuthProxyAuthCallback to invoke on completion
+ * @weak_object: #GObject to weakly reference and tie the lifecycle of the method call too
+ * @user_data: user data to pass to @callback
+ * @error: a #GError, or %NULL
+ *
+ * Perform the Access Token phase of OAuth, invoking @function (defaulting to
+ * "access_token" if @function is NULL).
+ *
+ * @verifier is only used if the server supports OAuth 1.0a. This is either the
+ * %oauth_verifier parameter that was passed to your callback URI, or a string
+ * that the user enters in some other manner (for example in a popup dialog) if
+ * "oob" was passed to oauth_proxy_request_token().
+ *
+ * This method will return once the method has been queued, @callback will be
+ * invoked when it has completed.
+ *
+ * Returns: %TRUE if the method was successfully queued, or %FALSE on
+ * failure. On failure @error is set.
+ */
+gboolean
+oauth_proxy_access_token_async (OAuthProxy *proxy,
+ const char *function,
+ const char *verifier,
+ OAuthProxyAuthCallback callback,
+ GObject *weak_object,
+ gpointer user_data,
+ GError **error)
+{
+ RestProxyCall *call;
+ AuthData *data;
+
+ call = rest_proxy_new_call (REST_PROXY (proxy));
+ rest_proxy_call_set_function (call, function ? function : "request_token");
+
+ if (verifier)
+ rest_proxy_call_add_param (call, "oauth_verifier", verifier);
+
+ data = g_slice_new0 (AuthData);
+ data->callback = callback;
+ data->user_data = user_data;
+
+ return rest_proxy_call_async (call, auth_callback, weak_object, data, error);
+}
+
+/**
* oauth_proxy_get_token:
* @proxy: an #OAuthProxy
*
diff --git a/rest/oauth-proxy.h b/rest/oauth-proxy.h
index 5ecb011..d19fcb5 100644
--- a/rest/oauth-proxy.h
+++ b/rest/oauth-proxy.h
@@ -88,7 +88,8 @@ RestProxy* oauth_proxy_new_with_token (const char *consumer_key,
/**
* OAuthProxyAuthCallback:
*
- * Callback from oauth_proxy_auth_step_async().
+ * Callback from oauth_proxy_request_token_async() and
+ * oauth_proxy_access_token_async().
*/
typedef void (*OAuthProxyAuthCallback)(OAuthProxy *proxy,
GError *error,
@@ -100,6 +101,7 @@ gboolean oauth_proxy_auth_step (OAuthProxy *proxy,
const char *function,
GError **error);
+G_GNUC_DEPRECATED
gboolean oauth_proxy_auth_step_async (OAuthProxy *proxy,
const char *function,
OAuthProxyAuthCallback callback,
@@ -113,12 +115,27 @@ gboolean oauth_proxy_request_token (OAuthProxy *proxy,
const char *callback_uri,
GError **error);
+gboolean oauth_proxy_request_token_async (OAuthProxy *proxy,
+ const char *function,
+ const char *callback_uri,
+ OAuthProxyAuthCallback callback,
+ GObject *weak_object,
+ gpointer user_data,
+ GError **error);
gboolean oauth_proxy_access_token (OAuthProxy *proxy,
const char *function,
const char *verifier,
GError **error);
+gboolean oauth_proxy_access_token_async (OAuthProxy *proxy,
+ const char *function,
+ const char *verifier,
+ OAuthProxyAuthCallback callback,
+ GObject *weak_object,
+ gpointer user_data,
+ GError **error);
+
/* TODO async forms of request and access token */
const char * oauth_proxy_get_token (OAuthProxy *proxy);