Browse Source

cient routing token access

master
sahabaishakhi 5 years ago
parent
commit
a0b80fbc8a
3 changed files with 21 additions and 11 deletions
  1. +2
    -1
      figwheel-main.edn
  2. +17
    -8
      src/clj/googlefit_api_test/core.clj
  3. +2
    -2
      src/cljs/googlefit-api-test/core.cljs

+ 2
- 1
figwheel-main.edn View File

@@ -1 +1,2 @@
{:watch-dirs ["src/cljs"]}
{:watch-dirs ["src/cljs"]
:ring-handler googlefit-api-test.core/handler}

+ 17
- 8
src/clj/googlefit_api_test/core.clj View File

@@ -5,11 +5,20 @@
[ring.util.response :as resp]
[ring.middleware.reload :refer [wrap-reload]]))

(defroutes app-routes
(GET "/" [] (resp/resource-response "index.html" {:root "public"}))
(resources "/")
(not-found "<h1>Page not found</h1>"))

(defn -main []
(jetty/run-jetty (wrap-reload #'app-routes) {:port 8000})
(println (str "Server is running on port 8000")))
;; (defroutes app-routes
;; (GET "/" [] (resp/resource-response "index.html" {:root "public"}))
;; (resources "/")
;; (not-found "<h1>Page not found</h1>"))

;; (defn -main []
;; (jetty/run-jetty (wrap-reload #'app-routes) {:port 8000})
;; (println (str "Server is running on port 8000")))

(def route-set #{"/" "/tokenpage"})

(defn handler [req]
(or
(when (route-set (:uri req))
(some-> (resp/resource-response "index.html" {:root "public"})
(resp/content-type "text/html; charset=utf-8")))
(not-found "Not found")))

+ 2
- 2
src/cljs/googlefit-api-test/core.cljs View File

@@ -11,11 +11,11 @@
(println fragment-string)

(defn appended-container [target]
(let [oauth2-end-point "https://accounts.google.com/o/oauth2/v2/auth?scope=https%3A//www.googleapis.com/auth/fitness.activity.read&include_granted_scopes=true&response_type=token&redirect_uri=http%3A//localhost%3A9500&client_id=857819587666-2pm3q0sv9lvmv697afm0k6jblgvtjon9.apps.googleusercontent.com"
(let [oauth2-end-point "https://accounts.google.com/o/oauth2/v2/auth?scope=https%3A//www.googleapis.com/auth/fitness.activity.read&include_granted_scopes=true&response_type=token&redirect_uri=http%3A//localhost%3A9500/tokenpage&client_id=857819587666-2pm3q0sv9lvmv697afm0k6jblgvtjon9.apps.googleusercontent.com"

form (r/atom (.createElement js/document "form"))
params {:client-id "857819587666-2pm3q0sv9lvmv697afm0k6jblgvtjon9.apps.googleusercontent.com"
:redirect-uri "http://localhost:9500"
:redirect-uri "http://localhost:9500/tokenpage"
:response-type "token"
:scope "https://www.googleapis.com/auth/fitness.activity.read"
:include-granted-scopes "true"}


Loading…
Cancel
Save