   [client-id secret]
   (find-by-key [client-id "refresh" secret]))
 
-(defn find-grant-token
+(defn find-granted-token
   [client-id login]
-  (find-by-key [client-id "grant" login]))
+  (find-by-key [client-id "login" login]))
 
 (defn purge-tokens
   []

  (revoke-all! *token-store* key))

(defn revoke-token
  "Revokes previously generated token based on its secret. "
  [token]
  (let [{:keys [client-id login secret refreshing]} token]

    ;; when refresh token is removed, corresponding
    ;; access-token and grant alias should be removed as well

    (revoke-one! *token-store* [client-id "access" (or refreshing secret)])

    (when refreshing
      (revoke-one! *token-store* [client-id "refresh" secret])
      (revoke-one! *token-store* [client-id "grant" login]))))

(defn create-token
  "Creates new token"


    (if (f/failed? access-token)
      access-token
      (let [refresh-token (or (find-granted-token (:id client) (:login user))
                              (create-token client user scope {:refreshing secret}))]

        (-> {:access_token secret
