Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

Merge pull request #37 from JeffreyPalmer/master

added create-auth and valid-auth? oauth functions
  • Loading branch information...
2 parents e4defc0 + 5f548d3 commit 51b59de7f73df5280342efa7ce0fd89adb66fc04 @Raynes committed
Showing with 29 additions and 4 deletions.
  1. +29 −4 src/tentacles/oauth.clj
33 src/tentacles/oauth.clj
@@ -1,11 +1,36 @@
(ns tentacles.oauth
(:use [tentacles.core :only [api-call no-content?]]))
-(defn authorizations [options]
+(defn authorizations
+ "List your authorizations."
+ [options]
(api-call :get "authorizations" nil options))
-(defn specific-auth [id & [options]]
+(defn specific-auth
+ "Get a specific authorization."
+ [id & [options]]
(api-call :get "authorizations/%s" [id] options))
-(defn delete-auth [id & [options]]
- (no-content? (api-call :delete "authorizations/%s" [id] options)))
+(defn delete-auth
+ "Delete an authorization."
+ [id & [options]]
+ (no-content? (api-call :delete "authorizations/%s" [id] options)))
+(defn create-auth
+ "Create a new authorization."
+ [options]
+ (api-call :post "authorizations" nil options))
+(defn valid-auth?
+ "Returns auth data if authorization is still valid, false otherwise.
+ OAuth applications can use this special API method for checking
+ OAuth token validity without running afoul of normal rate limits for
+ failed login attempts. Authentication works differently with this
+ particular endpoint. You must use Basic Authentication when
+ accessing it, where the username is the OAuth application client_id
+ and the password is its client_secret."
+ [client-id access-token & [options]]
+ (let [result (api-call :get "applications/%s/tokens/%s" [client-id access-token] options)]
+ (if (= (:status result) 404)
+ false
+ result)))

0 comments on commit 51b59de

Please sign in to comment.
Something went wrong with that request. Please try again.