Helpers for getting an OAuth 2.0 token. See https://developers.google.com/identity/protocols/OAuth2WebServer
Helpers for getting an OAuth 2.0 token. See https://developers.google.com/identity/protocols/OAuth2WebServer
(exchange-code {:keys [client_id client_secret redirect_uri]} code)
Step 5: Exchange authorization code for refresh and access tokens. When the user is redirected back to your app from Google with a short lived code, exchange the code for a long lived access token.
Step 5: Exchange authorization code for refresh and access tokens. When the user is redirected back to your app from Google with a short lived code, exchange the code for a long lived access token.
(maybe-grow-scopes config {:as credentials :keys [scopes]} new-scopes optional)
Incremental authorization. Given a credentials map, re-authorizes with additional scopes. Include previous scopes when asking for new scopes. Scopes are a vector of urls. Credentials contain tokens and scopes. Returns the URL to redirect the user to, or nil if the scopes are already authorized.
Incremental authorization. Given a credentials map, re-authorizes with additional scopes. Include previous scopes when asking for new scopes. Scopes are a vector of urls. Credentials contain tokens and scopes. Returns the URL to redirect the user to, or nil if the scopes are already authorized.
(redirect-from-google config {{:keys [code]} :params})
Step 4: Handle the OAuth 2.0 server response.
In your app server, create a route :redirect-uri
receives the code
parameter.
Step 4: Handle the OAuth 2.0 server response. In your app server, create a route `:redirect-uri` receives the `code` parameter.
(refresh-token {:keys [client_id client_secret]} {:keys [refresh_token]})
Given a config map, and a credentials map containing a refresh_token, fetches a new access token. Returns the response if successful, which is a map of credentials containing an access token. Refresh tokens eventually expire, and attempts to refresh will fail with 401. Therefore, calls that could cause a refresh should catch 401 exceptions, call set-authorization-parameters and redirect.
Given a config map, and a credentials map containing a refresh_token, fetches a new access token. Returns the response if successful, which is a map of credentials containing an access token. Refresh tokens eventually expire, and attempts to refresh will fail with 401. Therefore, calls that could cause a refresh should catch 401 exceptions, call set-authorization-parameters and redirect.
(revoke-token {:keys [access_token refresh_token]})
Given a credentials map containing either an access token or refresh token, revokes them.
Given a credentials map containing either an access token or refresh token, revokes them.
(set-authorization-parameters config scopes)
(set-authorization-parameters {:as config :keys [client_id redirect_uri]}
scopes
{:as optional :keys [state login_hint]})
Step 1: Set authorization parameters. We tell Google to expect a visit from our user. Returns the URL to redirect the user to.
Step 1: Set authorization parameters. We tell Google to expect a visit from our user. Returns the URL to redirect the user to.
(with-timestamp {:keys [expires_in] :as token-response})
Google won't give us the time of day, so let's check our clock.
Google won't give us the time of day, so let's check our clock.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close