Git Product home page Git Product logo

oauth-clj's Introduction

OAUTH-CLJ

Build Status Dependencies Status Gittip

A clj-http compatible OAuth library for Clojure.

Installation

Via Clojars: http://clojars.org/oauth-clj.

Current Version

Usage

(use 'oauth.twitter)

Define your consumer key and secret.

(def consumer-key "qcz2O57srPsb5eZA2Jyw")
(def consumer-secret "lfs5WjmIzPc3OlDNoHSfbxVBmPNmduTDq4rQHhNN7Q")

Obtain a OAuth request token from Twitter to request user authorization.

(def request-token (oauth-request-token consumer-key consumer-secret))
;;=> {:oauth-callback-confirmed "true",
;;=>  :oauth-token-secret "1TPRuaqWZ9Y9viEdKbU4SQ2QsF5auLcMZaHOwYLK2ao",
;;=>  :oauth-token "C6FCXGYUIutgTZZP1EAAx2nT0cv8QO15K4EbjbzOmBs"}

Send the user to Twitter's authorization endpoint.

(oauth-authorize (:oauth-token request-token))

Parse the parameters in your oauth callback endpoint.

(def authorization
  {:oauth-verifier "ZCpKl8mgIUJmTkO8rfBeFotrKKd84igvytvLqlzo"
   :oauth-token "a5wQRcMsl5BMSPTmxZG5ER8OzMH6jdG4kX4uPtbC4Rw"})

Obtain the OAuth access token from Twitter.

(def access-token
  (oauth-access-token
   consumer-key
   (:oauth-token authorization)
   (:oauth-verifier authorization)))

Make a clj-http OAuth client.

(def client
  (oauth-client
   consumer-key
   consumer-secret
   (:oauth-token access-token)
   (:oauth-verifier access-token)))

Post a Tweet ...

(client
 {:method :post
  :url "http://api.twitter.com/1/statuses/update.json"
  :body (str "status=setting%20up%20my%20twitter%20私のさえずりを設定する")})

License

Copyright (C) 2012-2014 r0man

Distributed under the Eclipse Public License, the same as Clojure.

oauth-clj's People

Contributors

canweriotnow avatar danielsz avatar gregspurrier avatar metajack avatar r0man avatar tobiasjewson avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.