                    :body (format "Something went wrong: status of underlying request %s" (:status at-resp))}
 
 
-                  (let [app-session-id (get-session-id req APP-SESSION-ID)
-                        original-uri (get-session-value req APP-SESSION-ID (:session-store this) :original-uri)
+                  (let [original-uri (get-data (:browser-session this) req :original-uri)
                         access-token (get (:body at-resp) "access_token")
 
                         ;; TODO If scope not there it is the same as

                        id-token (-> (get (:body at-resp) "id_token") str->jwt)]
                    (if (verify id-token "secret")
                      (do
                        (infof "Verified id_token: %s" id-token)
                        (assert original-uri (str "Failed to get original-uri from session " app-session-id))
                        (assoc-session! (:session-store this) app-session-id :access-token access-token)

                        (infof "Scope is %s" scope)
                        (assoc-session! (:session-store this) app-session-id :scope scope)

                        (infof "Claims are %s" (:claims id-token))
                        (assoc-session! (:session-store this) app-session-id :open-id (-> id-token :claims))
                        (redirect original-uri))))))))))
      wrap-params)

     ::logout (fn [req]
                (purge-session! (:session-store this) (get-session-id req APP-SESSION-ID))
                (if location-after-logout
                  (redirect location-after-logout)
                  {:status 200

   [modular.bidi :refer (WebService)]
   [cylon.oauth.client :refer (AccessTokenGrantee UserIdentity solicit-access-token)]
   [cylon.authorization :refer (RequestAuthorizer)]
   [cylon.session :refer (create-and-attach! get-data exists? ->cookie get-session assoc-session! create-session! cookies-response-with-session get-session-value get-session-id purge-session! remove! assoc-data!)]
   [ring.middleware.cookies :refer (wrap-cookies cookies-request cookies-response)]
   [ring.util.response :refer (redirect)]
   [ring.middleware.params :refer (wrap-params)]
