Created
November 19, 2012 00:36
Revisions
-
deadprogram revised this gist
Nov 19, 2012 . 1 changed file with 24 additions and 23 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -9,30 +9,31 @@ (defpage "/" [] (let [] (common/layout [:div [:h1 "ATT OAuth Demo"] [:a {:href "/auth"} "Get Profile"]]))) (defpage "/auth" [] (let [ auth-url (build-authorization-url { :authorization-url (str "https://" (get (System/getenv) "AUTH_SERVER") "/oauth/authorize") :client-id (get (System/getenv) "CLIENT_ID")} { :redirect-uri "http://localhost:4567/auth/callback" :scope :profile })] (redirect auth-url))) (defpage "/auth/callback" {:keys [code]} (let [ token (fetch-token { :token-url (str "https://" (get (System/getenv) "AUTH_SERVER") "/oauth/token") :client-id (get (System/getenv) "CLIENT_ID") :client-secret (get (System/getenv) "CLIENT_SECRET")} { :code code :insecure? true :redirect-uri "http://localhost:4567/auth/callback"}) profile-data (:body (client/get (str "https://" (get (System/getenv) "AUTH_SERVER") "/me.json") { :as :json :accept :json :oauth-token (:access-token token) :insecure? true }))] (common/layout [:div [:h1 "profile-data"] [:p (str profile-data)]]))) -
deadprogram revised this gist
Nov 19, 2012 . 2 changed files with 15 additions and 15 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,11 +6,11 @@ Example of accessing ATT OAuth in Clojure using noir. ```bash lein deps CLIENT_ID=XXX CLIENT_SECRET=YYY AUTH_SERVER=xyz.com lein run ``` ## License Copyright (C) 2012 The Hybrid Group Distributed under the MIT License This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,36 +2,36 @@ (:require [att-oauth-client.views.common :as common] [clj-http.client :as client]) (:use [noir.core :only [defpage custom-handler]] [noir.response :only [redirect]] [hiccup.core :only [html]] [oauthentic.core])) (defpage "/" [] (let [] (common/layout [:div [:h1 "ATT OAuth Demo"] [:a {:href "/auth"} "Get Profile"]]))) (defpage "/auth" [] (redirect (build-authorization-url { :authorization-url (str "https://" (get (System/getenv) "AUTH_SERVER") "/oauth/authorize") :client-id (get (System/getenv) "CLIENT_ID")} { :redirect-uri "http://localhost:4567/auth/callback" :scope :profile }))) (defpage "/auth/callback" {:keys [code]} (let [ token (fetch-token {:token-url (str "https://" (get (System/getenv) "AUTH_SERVER") "/oauth/token") :client-id (get (System/getenv) "CLIENT_ID") :client-secret (get (System/getenv) "CLIENT_SECRET")} {:code code :insecure? true :redirect-uri "http://localhost:4567/auth/callback"}) profile-data (:body (client/get (str "https://" (get (System/getenv) "AUTH_SERVER") "/me.json") { :as :json :accept :json :oauth-token (:access-token token) :insecure? true }))] (common/layout [:div [:h1 "profile-data"] -
deadprogram revised this gist
Nov 19, 2012 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -16,20 +16,20 @@ (defpage "/auth" [] (redirect (build-authorization-url { :authorization-url "https://75.55.105.49/oauth/authorize" :client-id (get (System/getenv) "CLIENT_ID")} { :redirect-uri "http://localhost:4567/auth/callback" :scope :profile }))) (defpage "/auth/callback" {:keys [code]} (let [ token (fetch-token {:token-url "https://75.55.105.49/oauth/token" :client-id (get (System/getenv) "CLIENT_ID") :client-secret (get (System/getenv) "CLIENT_SECRET")} {:code code :insecure? true :redirect-uri "http://localhost:4567/auth/callback"}) profile-data (:body (client/get "https://75.55.105.49/me.json" { :as :json :accept :json :oauth-token (:access-token token) :insecure? true } ))] (common/layout -
deadprogram created this gist
Nov 19, 2012 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,16 @@ # ATT OAuth2 Clojure Client Example of accessing ATT OAuth in Clojure using noir. ## Usage ```bash lein deps lein run ``` ## License Copyright (C) 2012 The Hybrid Group Distributed under the MIT License This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,6 @@ (defproject att-oauth-client "0.1.0-SNAPSHOT" :description "Example of accessing ATT OAuth in Clojure using noir" :dependencies [[org.clojure/clojure "1.3.0"] [noir "1.2.1"] [org.clojars.deadprogram/oauthentic "1.0.4"]] :main att-oauth-client.server) This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,10 @@ (ns att-oauth-client.server (:require [noir.server :as server])) (server/load-views "src/att_oauth_client/views/") (defn -main [& m] (let [mode (keyword (or (first m) :dev)) port (Integer. (get (System/getenv) "PORT" "4567"))] (server/start port {:mode mode :ns 'att-oauth-client}))) This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,38 @@ (ns att-oauth-client.views.welcome (:require [att-oauth-client.views.common :as common] [clj-http.client :as client]) (:use [noir.core :only [defpage custom-handler]] [noir.response :only [redirect]] [hiccup.core :only [html]] [oauthentic.core])) (defpage "/" [] (let [] (common/layout [:div [:h1 "ATT OAuth Demo"] [:a {:href "/auth"} "Get Profile"]]))) (defpage "/auth" [] (redirect (build-authorization-url { :authorization-url "https://75.55.105.49/oauth/authorize" :client-id (get (System/getenv) "CLIENT_ID")} { :redirect-uri "http://localhost:4567/auth/callback" :scope :profile }))) (defpage "/auth/callback" {:keys [code]} (let [ token (fetch-token {:token-url "https://75.55.105.49/oauth/token" :client-id (get (System/getenv) "CLIENT_ID") :client-secret (get (System/getenv) "CLIENT_SECRET")} {:code code :insecure? true :redirect-uri "http://localhost:4567/auth/callback"}) profile-data (:body (client/get "https://75.55.105.49/me.json" { :as :json :accept :json :oauth-token (:access-token token) :insecure? true } ))] (common/layout [:div [:h1 "profile-data"] [:p (str profile-data)]])))