Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Update to match erlang-oauth v1.2.0

  • Loading branch information...
commit d3b62d47a5baebddd6d80b4d0ffac54e4ddb25d0 1 parent 00649ad
@tim authored
View
57 src/oauth_client.erl
@@ -65,7 +65,7 @@ stop(Client) ->
%%============================================================================
oauth_get(header, URL, Params, Consumer, Token, TokenSecret) ->
- Signed = oauth:signed_params("GET", URL, Params, Consumer, Token, TokenSecret),
+ Signed = oauth:sign("GET", URL, Params, Consumer, Token, TokenSecret),
{AuthorizationParams, QueryParams} = lists:partition(fun({K, _}) -> lists:prefix("oauth_", K) end, Signed),
Request = {oauth:uri(URL, QueryParams), [oauth:header(AuthorizationParams)]},
httpc:request(get, Request, [{autoredirect, false}], []);
@@ -81,51 +81,42 @@ init(Consumer) ->
handle_call({get_request_token, URL, Params, ParamsMethod}, _From, State={Consumer}) ->
case oauth_get(ParamsMethod, URL, Params, Consumer, "", "") of
+ {ok, Response={{_, 200, _}, _, _}} ->
+ RParams = oauth:params_decode(Response),
+ {reply, {ok, oauth:token(RParams)}, {Consumer, RParams}};
{ok, Response} ->
- case oauth_http:response_code(Response) of
- 200 ->
- RParams = oauth_http:response_params(Response),
- {reply, {ok, oauth:token(RParams)}, {Consumer, RParams}};
- _ ->
- {reply, Response, State}
- end;
+ {reply, Response, State};
Error ->
{reply, Error, State}
end;
handle_call({get_access_token, URL, Params, ParamsMethod}, _From, State={Consumer, RParams}) ->
case oauth_get(ParamsMethod, URL, Params, Consumer, oauth:token(RParams), oauth:token_secret(RParams)) of
+ {ok, Response={{_, 200, _}, _, _}} ->
+ AParams = oauth:params_decode(Response),
+ {reply, ok, {Consumer, RParams, AParams}};
{ok, Response} ->
- case oauth_http:response_code(Response) of
- 200 ->
- AParams = oauth_http:response_params(Response),
- {reply, ok, {Consumer, RParams, AParams}};
- _ ->
- {reply, Response, State}
- end;
+ {reply, Response, State};
Error ->
{reply, Error, State}
end;
handle_call({get, URL, Params, ParamsMethod}, _From, State={Consumer, _RParams, AParams}) ->
case oauth_get(ParamsMethod, URL, Params, Consumer, oauth:token(AParams), oauth:token_secret(AParams)) of
- {ok, Response={{_, Status, _}, Headers, Body}} ->
- case Status of
- 200 ->
- case proplists:get_value("content-type", Headers) of
- undefined ->
- {reply, {ok, Headers, Body}, State};
- ContentType ->
- MediaType = hd(string:tokens(ContentType, ";")),
- case lists:suffix("/xml", MediaType) orelse lists:suffix("+xml", MediaType) of
- true ->
- {XML, []} = xmerl_scan:string(Body),
- {reply, {ok, Headers, XML}, State};
- false ->
- {reply, {ok, Headers, Body}, State}
- end
- end;
- _ ->
- {reply, Response, State}
+ {ok, {{_, 200, _}, Headers, Body}} ->
+ case proplists:get_value("content-type", Headers) of
+ undefined ->
+ {reply, {ok, Headers, Body}, State};
+ ContentType ->
+ MediaType = hd(string:tokens(ContentType, ";")),
+ case lists:suffix("/xml", MediaType) orelse lists:suffix("+xml", MediaType) of
+ true ->
+ {XML, []} = xmerl_scan:string(Body),
+ {reply, {ok, Headers, XML}, State};
+ false ->
+ {reply, {ok, Headers, Body}, State}
+ end
end;
+ {ok, Response} ->
+ {reply, Response, State};
Error ->
{reply, Error, State}
end;
View
2  src/oauth_gcal.erl
@@ -57,7 +57,7 @@ get_feed(Client) ->
{{_, 302, _}, Headers, _} = oauth_client:get(Client, URL),
Location = proplists:get_value("location", Headers),
{_, _, _, _, _, [$?|Params]} = http_uri:parse(Location),
- Gsessionid = proplists:lookup("gsessionid", oauth_uri:params_from_string(Params)),
+ Gsessionid = proplists:lookup("gsessionid", oauth:uri_params_decode(Params)),
oauth_client:get(Client, URL, [Gsessionid]).
feed_titles(XML) ->
View
2  src/oauth_mochiweb_client.erl
@@ -34,7 +34,7 @@ echo(Client) ->
echo(Client, Params) ->
case oauth_client:get(Client, "http://0.0.0.0:8000/echo", Params, querystring) of
{ok, _Headers, Body} ->
- {ok, lists:keysort(1, oauth_uri:params_from_string(Body))};
+ {ok, lists:keysort(1, oauth:uri_params_decode(Body))};
Error ->
Error
end.
View
2  src/oauth_mochiweb_server.erl
@@ -84,7 +84,7 @@ serve_echo(Request) ->
case oauth:verify(Signature, "GET", URL, Params, Consumer, "accesssecret") of
true ->
EchoParams = lists:filter(fun({K, _}) -> not lists:prefix("oauth_", K) end, Params),
- ok(Request, oauth_uri:params_to_string(EchoParams));
+ ok(Request, oauth:uri_params_encode(EchoParams));
false ->
bad(Request, "invalid signature value.")
end;
View
2  src/oauth_termie.erl
@@ -48,7 +48,7 @@ echo(Client, Params) ->
URL = "http://term.ie/oauth/example/echo_api.php",
case oauth_client:get(Client, URL, Params, querystring) of
{ok, _Headers, Body} ->
- {ok, lists:keysort(1, oauth_uri:params_from_string(Body))};
+ {ok, lists:keysort(1, oauth:uri_params_decode(Body))};
Error ->
Error
end.
Please sign in to comment.
Something went wrong with that request. Please try again.