My interpretation of the OAuth 1.0 protocol, based on my reading of RFC5849, the liboauth C library and factoring out the OAuth authentication code from Twitter.jl. At one point, this package relied on liboauth and was a wrapper of that library's functions built using Clang.jl; however, as I cleaned up the auto-generated functions from Clang, I decided that it would be easier and cleaner to re-write the library in Julia rather than require liboauth.

This is still a work-in-progress, but works as a replacement for the authentication in the Twitter.jl package, so it should be fairly complete in its implementation.

- [Functions](index.md#Functions-1)
- [Index](index.md#Index-1)

Functions

# OAuth.encodeURI!Method.

encodeURI!(dict_of_parameters::Dict)

Mutates dict_of_parameters using encodeURI on strings.

Examples

julia> encodeURI!(Dict("iv" => 10, "s" => "value!"))
Dict{String,Any} with 2 entries:
  "iv" => 10
  "s"  => "value%21"

source

# OAuth.encodeURIMethod.

encodeURI(s)

Convenience function for HTTP.escapeuri.

Examples

julia> encodeURI("hello, world!")
"hello%2C%20world%21"

source

# OAuth.oauth_body_hash_dataMethod.

oauth_body_hash_data(data::String)

Returns oauth_body_hash= along with base64 encoded SHA-1 from input.

Examples

julia> oauth_body_hash_data("Hello, World!")
"oauth_body_hash=CgqfKmdylCVXq1NV12r0Qvj2XgE="

source

# OAuth.oauth_body_hash_encodeMethod.

oauth_body_hash_encode(data::String)

Convenience function for SHA-1 and base64 encoding.

Examples

julia> oauth_body_hash_encode("julialang")
"Lsztg2byou89Y8lBoH3G8v3vjbw="

source

# OAuth.oauth_body_hash_fileMethod.

oauth_body_hash_file(filename::String)

Returns oauth_body_hash= along with base64 encoded SHA-1 from input text file.

Examples

julia> oauth_body_hash_file(joinpath(Pkg.dir(), "OAuth/test/auth_body_hash_file.txt"))
"oauth_body_hash=CgqfKmdylCVXq1NV12r0Qvj2XgE="

source

# OAuth.oauth_headerMethod.

function oauth_header(httpmethod, baseurl, options, oauth_consumer_key, oauth_consumer_secret, oauth_token, oauth_token_secret; oauth_signature_method = "HMAC-SHA1", oauth_version = "1.0")

Builds OAuth header, defaulting to OAuth 1.0. Function assumes options has already been run through encodeURI!.

source

# OAuth.oauth_nonceMethod.

oauth_nonce(length::Int)

Returns a random string of a given length.

Examples

julia> oauth_nonce(10)
"aQb2FVkrYi"

source

# OAuth.oauth_percent_encode_keys!Method.

oauth_percent_encode_keys!(options::Dict)

Returns dict where keys and values are URL-encoded.

Examples

julia> oauth_percent_encode_keys!(Dict("key 1" => "value1", "key    2" => "value 2"))
Dict{String,String} with 2 entries:
  "key%20%20%20%202" => "value%202"
  "key%201"          => "value1"

source

# OAuth.oauth_request_resourceMethod.

oauth_request_resource(endpoint::String, httpmethod::String, options::Dict, oauth_consumer_key::String, oauth_consumer_secret::String, oauth_token::String, oauth_token_secret::String)

Makes GET or POST call to OAuth API.

source

# OAuth.oauth_serialize_url_parametersMethod.

oauth_serialize_url_parameters(options::Dict)

Returns query string by concatenating dictionary keys/values.

Examples

julia> oauth_serialize_url_parameters(Dict("foo" => "bar", "foo 1" => "hello!"))
"foo=bar&foo 1=hello!"

source

# OAuth.oauth_sign_hmac_sha1Method.

oauth_sign_hmac_sha1(message::String, signingkey::String)

Takes a message and signing key, converts to a SHA-1 digest, then encodes to base64.

Examples

julia> oauth_sign_hmac_sha1("foo", "bar")
"hdFVxV7ShqMAvRzxJN4I2H6RTzo="

source

# OAuth.oauth_signature_base_stringMethod.

oauth_signature_base_string(httpmethod::String, url::String, parameterstring::String)

Returns encoded HTTP method, url and parameters.

Examples

julia> oauth_signature_base_string("POST", "https://julialang.org", "foo&bar")
"POST&https%3A%2F%2Fjulialang.org&foo%26bar"

source

# OAuth.oauth_signing_keyMethod.

oauth_signing_key(oauth_consumer_secret::String, oauth_token_secret::String)

Returns a signing key based on a consumer secret and token secret.

Examples

julia> oauth_signing_key("foo", "bar")
"foo&bar"

source

# OAuth.oauth_timestampMethod.

oauth_timestamp()

Returns current unix timestamp as String.

Examples

julia> oauth_timestamp()
"1512235859"

source

Index