weavejester / ring-oauth2

OAuth 2.0 client middleware for Ring
146 stars 38 forks source link

Allow authorization URI to be configured as a function #45

Open Kah0ona opened 3 years ago

Kah0ona commented 3 years ago

This PR is created to support the situation where the :authorize-uri has some runtime dependent parts, like a subdomain. Then; one can configure it like so:

  (def profile 
       {:myservice {:authorize-uri (fn [profile request state] ,,,)
                     ,,,}})

Use case: In my SaaS app, I integrate with Shopify, and their authorize uri is like: https://{shop}.myshopify.com/admin/oauth/authorize?client_id={api_key}&scope={scopes}&redirect_uri={redirect_uri}&state={nonce}&grant_options[]={access_mode} where {shop} is dynamic and dependent on the logged in user of my SaaS app.