lexmag/oauther


An OAuth 1.0 for Elixir

License: ISC

Language: Elixir

Keywords: elixir, oauth


OAuther

Build Status Hex Version

Library to authenticate with OAuth 1.0 protocol.

Installation

Add OAuther as a dependency to your mix.exs file:

defp deps do
  [{:oauther, "~> 1.1"}]
end

After you are done, run mix deps.get in your shell to fetch the dependencies.

Usage

Example below shows the use of hackney HTTP client for interacting with the Twitter API. Protocol parameters are transmitted using the HTTP "Authorization" header field.

creds = OAuther.credentials(consumer_key: "dpf43f3p2l4k3l03", consumer_secret: "kd94hf93k423kf44", token: "nnch734d00sl2jdk", token_secret: "pfkkdhi9sl3r4s00")
#=> %OAuther.Credentials{
#=>   consumer_key: "dpf43f3p2l4k3l03",
#=>   consumer_secret: "kd94hf93k423kf44",
#=>   method: :hmac_sha1,
#=>   token: "nnch734d00sl2jdk",
#=>   token_secret: "pfkkdhi9sl3r4s00"
#=> }
params = OAuther.sign("post", "https://api.twitter.com/1.1/statuses/lookup.json", [{"id", 485086311205048320}], creds)
#=> [
#=>   {"oauth_signature", "ariK9GrGLzeEJDwQcmOTlf7jxeo="},
#=>   {"oauth_consumer_key", "dpf43f3p2l4k3l03"},
#=>   {"oauth_nonce", "L6a3Y1NeNwbU9Sqd6XnwNU+pjm6o0EyA"},
#=>   {"oauth_signature_method", "HMAC-SHA1"},
#=>   {"oauth_timestamp", 1517250224},
#=>   {"oauth_version", "1.0"},
#=>   {"oauth_token", "nnch734d00sl2jdk"},
#=>   {"id", 485086311205048320}
#=> ]
{header, req_params} = OAuther.header(params)
#=> {{"Authorization",
#=>   "OAuth oauth_signature=\"ariK9GrGLzeEJDwQcmOTlf7jxeo%3D\", oauth_consumer_key=\"dpf43f3p2l4k3l03\", oauth_nonce=\"L6a3Y1NeNwbU9Sqd6XnwNU%2Bpjm6o0EyA\", oauth_signature_method=\"HMAC-SHA1\", oauth_timestamp=\"1517250224\", oauth_version=\"1.0\", oauth_token=\"nnch734d00sl2jdk\""},
#=>  [{"id", 485086311205048320}]}
:hackney.post("https://api.twitter.com/1.1/statuses/lookup.json", [header], {:form, req_params})
#=> {:ok, 200, [...], #Reference<0.0.0.837>}

License

OAuther is released under the ISC license.

Project Statistics

Sourcerank 10
Repository Size 23.4 KB
Stars 42
Forks 14
Watchers 6
Open issues 2
Dependencies 0
Contributors 5
Tags 5
Created
Last updated
Last pushed

Top Contributors See all

Aleksei Magusev Udo Kramer Gustavo Giménez Low Kian Seong Bryan Enders

Packages Referencing this Repo

oauther
Library to authenticate with OAuth 1.0 protocol.
Latest release 1.1.1 - Updated - 42 stars

Recent Tags See all

v1.1.1 January 29, 2018
v1.1.0 October 28, 2016
v1.0.2 September 12, 2015
v1.0.1 August 03, 2014
v1.0.0 July 05, 2014

Interesting Forks See all

spartansystems/oauther
An OAuth 1.0 for Elixir
Elixir - Last pushed - 1 stars

Something wrong with this page? Make a suggestion

Last synced: 2018-01-29 19:32:08 UTC

Login to resync this repository