Skip to content

xQuery lib for creating oAuth 1 protocol Authorization Headers for Twitter API calls

Notifications You must be signed in to change notification settings

grantmacken/oAuth1

Repository files navigation

Creating oAuth 1 protocol Authorization header strings in xQuery

Create Authorization Headers for Twitter API calls via xQuery

Build Status

latest release

GitHub tag GitHub release

This lib only purpose is to enable calls to Twitter API endpoints via OAuth 1.0a protocol Authorization Header

Built upon 'http://expath.org/ns/crypto' cypto lib, version: 0.6' which provides the cypto:hmac function to calculate the signature.

Prior to using this library

You must obtain your twitter access token from the twitter apps dashboard You will end up with your 4 credential items

  1. oauth_consumer_key
  2. oauth_consumer_secret
  3. oauth_token_secret
  4. oauth_token

Next make yourself familiar with the Twitter API docs

The API call you are most likely interest in are in the post and engage overview section

Creating a Authorization Header

Th following example shows how to use the library, with your obtained credentials. It creates the Authorization header string required for posting a status update to the Twitter 'statuses/update' API endpoint. The example data ( oauth_consumer_key etc ) come from the twitter creating signatures and authorizing-requests example code. The same example data has been used to test the library.

declare
function oAuth1:example() as xs:string {
   map {
    'method' : 'POST',
    'resource' : 'https://api.twitter.com/1.1/statuses/update',
    'oauth_consumer_key' : 'xvz1evFS4wEEPTGEFPHBog',
    'oauth_consumer_secret' : 'kAcSOqF21Fu85e7zjz7ZN2U4ZRhfV3WpwPAoE3Z7kBw',
    'oauth_token_secret' : '370773112-GmHxMAgYyLbNEtIKZeRNFsMKPR9EyMZeS9weJAEb',
    'oauth_token' : 'LswwdoUaIvS8ltyTt5jkRh4J50vUPVVHtR2YPi5kE'
    }
   ) =>
    oAuth1:authorizationHeader(
    map { 'status' : 'Hello Ladies + Gentlemen, a signed OAuth request!' }
    )
)
};


Building From Source

Repo Test Scaffolding

├── Makefile => run `make test` calls `prove -v bin/xQtest`
├── bin
│   ├── xQtest -> produce TAP report

asciicast

very simple smoke test

see if output from running example matches prescribed grep pattern

├── Makefile => run `make smoke` calls `bin/xQcall`
├── bin
│   ├── xQcall -> runs example

very very simple coverage

See if every function was called in lib by running example then inspecting trace

├── Makefile => run `make coverage `bin/xQcall`
├── bin
│   ├── xQcall -> enable tracing 
               -> run example 
               -> stop tracing 
               -> inpect trace

About

xQuery lib for creating oAuth 1 protocol Authorization Headers for Twitter API calls

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published