Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Update oauth_mochiweb_client to new oauth_client usage.

  • Loading branch information...
commit 4cb480f45bb3b88938c8b3baeae66335b73cb664 1 parent f6ad261
Tim Fletcher tim authored

Showing 1 changed file with 26 additions and 16 deletions. Show diff stats Hide diff stats

  1. +26 16 src/oauth_mochiweb_client.erl
42 src/oauth_mochiweb_client.erl
@@ -3,28 +3,38 @@
3 3 %%
4 4 %% Usage is the same as oauth_termie.
5 5 %%
6   -
7 6 -module(oauth_mochiweb_client).
8 7
9 8 -compile(export_all).
10 9
  10 +start() ->
  11 + start(hmac_sha1).
  12 +
  13 +start(SigMethod) when is_atom(SigMethod) ->
  14 + start(consumer(SigMethod));
  15 +start(Consumer) ->
  16 + oauth_client:start(Consumer).
  17 +
  18 +consumer(rsa_sha1) ->
  19 + {"key", "data/rsa_pkey.pem", rsa_sha1};
  20 +consumer(SigMethod) ->
  21 + {"key", "secret", SigMethod}.
11 22
12   -echo() ->
13   - oauth_termie(echo, []).
  23 +get_request_token(Client) ->
  24 + URL = "http://0.0.0.0:8000/oauth/request_token",
  25 + oauth_client:get_request_token(Client, URL, [], querystring).
14 26
15   -echo(Params) ->
16   - oauth_termie(echo, [Params]).
  27 +get_access_token(Client) ->
  28 + URL = "http://0.0.0.0:8000/oauth/access_token",
  29 + oauth_client:get_access_token(Client, URL, [], querystring).
17 30
18   -echo(Params, Consumer) ->
19   - oauth_termie(echo, [Params, Consumer]).
  31 +echo(Client) ->
  32 + echo(Client, [{"bar", "baz"}, {"method", "foo"}]).
20 33
21   -oauth_termie(F, Args) ->
22   - case get(oauth_termie_request_token_url) of
23   - undefined ->
24   - put(oauth_termie_request_token_url, "http://0.0.0.0:8000/oauth/request_token"),
25   - put(oauth_termie_access_token_url, "http://0.0.0.0:8000/oauth/access_token"),
26   - put(oauth_termie_echo_url, "http://0.0.0.0:8000/echo"),
27   - apply(oauth_termie, F, Args);
28   - _ ->
29   - apply(oauth_termie, F, Args)
  34 +echo(Client, Params) ->
  35 + case oauth_client:get(Client, "http://0.0.0.0:8000/echo", Params, querystring) of
  36 + {ok, _Headers, Body} ->
  37 + {ok, lists:keysort(1, oauth_uri:params_from_string(Body))};
  38 + Error ->
  39 + Error
30 40 end.

0 comments on commit 4cb480f

Please sign in to comment.
Something went wrong with that request. Please try again.