Giter VIP home page Giter VIP logo

Comments (4)

weavejester avatar weavejester commented on June 10, 2024

What does the redirect-uri do?

It's the URI that the authorization server uses to send the user back to the your app. In the OAuth 2.0 specification it's called the "redirection endpoint URI".

The URI is handled by the middleware itself, receiving the token and adding it to the session. When it's done, it redirects the user again to the landing URI.

It appears that each provider returns different data sets and that this library doesn't seem to handle the POST back to get the actual data I'm trying to access (email read only in my scenario).

No, but it should be straightforward. You need to add the token to a header on your POST request, like:

Authorization: Bearer <token>

How that's done depends on which HTTP client library you're using.

from ring-oauth2.

earthtrip avatar earthtrip commented on June 10, 2024

Thanks for the quick response. So is there no way to do processing inside the redirect-uri handler? It appears to just get auto-handled by ring-oauth2? I'm just trying to figure out where in my code I would do the POST back with the Bearer token. It seems a bit odd to me to do that in the landing-uri but that may just be because I think of a "landing" page to be where you want to redirect the user after all the oauth processing work is done vs having different landing-uri's for each provider that do POST's back to the provider and then render something to the browser.

e.g. this code never gets to the debug println statement

;; github oauth2
(defn oauth-github-launch [])

(defn oauth-github-callback [request]
  (println "got here")
  )


(defroutes github-oauth2-routes
  (GET "/auth/github" []
       (oauth-github-launch))
  (GET "/auth/github/callback" request
       (oauth-github-callback request)))


I have this in my middleware

(mount/defstate app
  :start
  (middleware/wrap-base
   (routes
    (-> #'home-routes
        (wrap-routes middleware/wrap-csrf)
        (wrap-routes middleware/wrap-formats))
    (-> #'github-oauth2-routes
        (wrap-routes middleware/wrap-csrf)
        (wrap-routes middleware/wrap-formats)
        (wrap-routes middleware/wrap-github-oauth2))

from ring-oauth2.

weavejester avatar weavejester commented on June 10, 2024

I'm just trying to figure out where in my code I would do the POST back with the Bearer token.

Put it in the handler for the landing URI.

There is an issue #10 which suggests adding a success handler that would be executed by the redirect URI, but aside from skipping a redirect the result would be the same as putting the logic in the landing URI instead.

from ring-oauth2.

earthtrip avatar earthtrip commented on June 10, 2024

OK cool. Many thanks!!

from ring-oauth2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.