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

auth-headerclj

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

credential-scopesclj

(credential-scopes credentials)
source

exchange-codeclj

(exchange-code {:keys [client_id client_secret redirect_uri redirect_uris
                       refresh_token]}
               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

has-scopes?clj

(has-scopes? credentials scopes)
source

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-credentialsclj

(refresh-credentials {:as config
                      :keys [client_id client_secret client_email private_key]}
                     scopes
                     {:as credentials :keys [refresh_token]})

Given a config map, and a credentials map containing either a refresh_token or private_key, 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 either a refresh_token or private_key,
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

refreshable?clj

(refreshable? {:as config :keys [private_key]}
              {:as credentials :keys [refresh_token]})
source

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

valid?clj

(valid? {:as credentials :keys [expires_at access_token]})
source

with-timestampclj

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

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

× close