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
(auth-header {:as credentials :keys [access_token]})
Given credentials, returns request header suitable for merging into a request.
Given credentials, returns request header suitable for merging into a request.
(exchange-code {:keys [client_id client_secret redirect_uri redirect_uris]}
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.
(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-credentials {:as config :keys [client_id client_secret]}
{:as credentials :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 redirect_uris]}
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 {:as credentials :keys [expires_in]})
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