summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoss Burton <ross@linux.intel.com>2009-04-27 15:57:45 +0100
committerRoss Burton <ross@linux.intel.com>2009-04-27 15:58:39 +0100
commita75a105a6f8a88a9e8897618c8b64e78fe87bac0 (patch)
treef0cf37f6b640e2b61f790539c02951bb928b2c8a
parent78eccb988e3168ea26b91d882983537f296ee80b (diff)
downloadlibrest-a75a105a6f8a88a9e8897618c8b64e78fe87bac0.tar.gz
Update OAuth example and test to new API
-rw-r--r--examples/test-oauth.c6
-rw-r--r--tests/oauth.c14
2 files changed, 12 insertions, 8 deletions
diff --git a/examples/test-oauth.c b/examples/test-oauth.c
index 5438502..1d56d28 100644
--- a/examples/test-oauth.c
+++ b/examples/test-oauth.c
@@ -43,7 +43,7 @@ main (int argc, char **argv)
"https://fireeagle.yahooapis.com/%s", TRUE);
/* First stage authentication, this gets a request token */
- oauth_proxy_auth_step (OAUTH_PROXY (proxy), "oauth/request_token");
+ oauth_proxy_auth_step (OAUTH_PROXY (proxy), "oauth/request_token", NULL);
/* From the token construct a URL for the user to visit */
g_print ("Go to https://fireeagle.yahoo.net/oauth/authorize?oauth_token=%s then hit any key\n",
@@ -51,8 +51,8 @@ main (int argc, char **argv)
getchar ();
/* Second stage authentication, this gets an access token */
- oauth_proxy_auth_step (OAUTH_PROXY (proxy), "oauth/access_token");
-
+ oauth_proxy_auth_step (OAUTH_PROXY (proxy), "oauth/access_token", NULL);
+
/* We're now authenticated */
g_print ("Got access token\n");
diff --git a/tests/oauth.c b/tests/oauth.c
index b7f7531..6ce1219 100644
--- a/tests/oauth.c
+++ b/tests/oauth.c
@@ -38,27 +38,29 @@ main (int argc, char **argv)
/* Create the proxy */
proxy = oauth_proxy_new ("key", "secret",
- "http://term.ie/oauth/example/%s",
- TRUE);
+ "http://term.ie/oauth/example/",
+ FALSE);
oproxy = OAUTH_PROXY (proxy);
g_assert (oproxy);
priv = PROXY_GET_PRIVATE (oproxy);
/* First stage authentication, this gets a request token */
- oauth_proxy_auth_step (oproxy, "request_token.php");
+ oauth_proxy_auth_step (oproxy, "request_token.php", &error);
+ g_assert_no_error (error);
g_assert_cmpstr (priv->token, ==, "requestkey");
g_assert_cmpstr (priv->token_secret, ==, "requestsecret");
/* Second stage authentication, this gets an access token */
- oauth_proxy_auth_step (OAUTH_PROXY (proxy), "access_token");
+ oauth_proxy_auth_step (OAUTH_PROXY (proxy), "access_token", &error);
+ g_assert_no_error (error);
g_assert_cmpstr (priv->token, ==, "accesskey");
g_assert_cmpstr (priv->token_secret, ==, "accesssecret");
/* Make some test calls */
- rest_proxy_bind (proxy, "echo_api.php");
call = rest_proxy_new_call (proxy);
+ rest_proxy_call_set_function (call, "echo_api.php");
rest_proxy_call_add_param (call, "foo", "bar");
if (!rest_proxy_call_run (call, NULL, &error))
g_error ("Cannot make call: %s", error->message);
@@ -66,6 +68,7 @@ main (int argc, char **argv)
g_object_unref (call);
call = rest_proxy_new_call (proxy);
+ rest_proxy_call_set_function (call, "echo_api.php");
rest_proxy_call_add_param (call, "numbers", "1234567890");
if (!rest_proxy_call_run (call, NULL, &error))
g_error ("Cannot make call: %s", error->message);
@@ -73,6 +76,7 @@ main (int argc, char **argv)
g_object_unref (call);
call = rest_proxy_new_call (proxy);
+ rest_proxy_call_set_function (call, "echo_api.php");
rest_proxy_call_add_param (call, "escape", "!£$%^&*()");
if (!rest_proxy_call_run (call, NULL, &error))
g_error ("Cannot make call: %s", error->message);