Liking cljdoc? Tell your friends :D

happy.oauth2

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
raw docstring

exchange-codeclj

(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.
sourceraw docstring

maybe-grow-scopesclj

(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.
sourceraw docstring

redirect-from-googleclj

(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.
sourceraw docstring

refresh-tokenclj

(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.
sourceraw docstring

revoke-tokenclj

(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.
sourceraw docstring

set-authorization-parametersclj

(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.
sourceraw docstring

with-timestampclj

(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.
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close