Skip to content

A library for generating and verifying OAuth 1.0a signatures. Supports the oauth_body_hash extension.

Notifications You must be signed in to change notification settings

camman3d/OAuthSigner

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OAuth 1.0a Signer and Verifier

By Joshua Monson

Summary

Description

This is a simple library that is designed to do one thing well: OAuth 1.0a Request Signing. This includes the body hash extension for content types other than application/x-www-form-urlencoded.

Motivation

After spending literally countless hours struggling with various OAuth library only to come to a realization that the authors either implemented the spec incorrectly or didn't implement the body hash extension, I finally broke in and wrote this library.

While I definitely have a preferred framework, this library was built web-framework agnostic so that is can be used in any without much difficulty.

Usage

Examples

To sign a request, create an OAuthRequest object and sign it with an OAuthKey object:

val key = OAuthKey("consumerKey", "consumerSecret", "tokenKey", "tokenSecret")
val request = OAuthRequest(None, None, "http://example.com", "one=two&three=4", "", "GET", "/resource")
val authHeader = request.getAuthorizationHeader(key)

You can also sign POST requests:

val key = OAuthKey("consumerKey", "consumerSecret", "tokenKey", "tokenSecret")
val request = OAuthRequest(None, Some("application/x-www-form-urlencoded"), "http://example.com", "", "username=billy", "POST", "/some/auth")
val authHeader = request.getAuthorizationHeader(key)

With the body hash extension, you can sign POST requests with other content types:

val key = OAuthKey("consumerKey", "consumerSecret", "tokenKey", "tokenSecret")
val request = OAuthRequest(None, Some("application/xml"), "http://example.com", "", "<parent><child></child></parent>", "POST", "/some/thing")
val authHeader = request.getAuthorizationHeader(key)

Given a request, you can verify that it is valid and correct given a key:

val key = OAuthKey("consumerKey", "consumerSecret", "tokenKey", "tokenSecret")
val authHeader = (get the Authorization header as a String)
val request = OAuthRequest(Some(authHeader), None, "http://example.com", "", "", "GET", "/another")
val valid = request.verify(key)

Documentation

The scaladoc is available here: http://joshmonson.com/oauthApi/#com.joshmonson.oauth.package

About

A library for generating and verifying OAuth 1.0a signatures. Supports the oauth_body_hash extension.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages