Git Product home page Git Product logo

Comments (4)

calebkleveter avatar calebkleveter commented on May 18, 2024 1

The redirect parameter in the ImperialMiddleware initializer is the path to redirect the client to if they are not authenticated.

I have outlined how to actually authenticate the user in the Google auth guide.

Basically you register the auth route like this:

try router.oAuth(from: Google.self, authenticate: "google", callback: "http://localhost:8080/google-complete")

Then the client can go to the /google route, which will redirect them to Google for sign-in.

from imperial.

gaetandezeiraud avatar gaetandezeiraud commented on May 18, 2024

Ok I see, thanks for your awnser.
But, I need to create the /google route? Because by default, I have just the message in log and not redirection. My code is:

try router.oAuth(from: Google.self, authenticate: "google", callback: "http://localhost:8080/google-complete", scope: ["https://www.googleapis.com/auth/cloud-platform"]) { (request, token) in
 print(token)
 return request.future(request.redirect(to: "/"))
 }

And

let protected = router.grouped(ImperialMiddleware())
protected.get("hello") { req in
        return "Hello, world!"
}

And I get {"error":true,"reason":"User currently not authenticated"} but no redirection.

If I need to create this route, how I can get the authURL available in GoogleRouter.swift with clientID, scope, etc?

Thanks you, for the project and your quick response!

from imperial.

calebkleveter avatar calebkleveter commented on May 18, 2024

The /google route is automatically created by the router.oAuth call. You should be good to go!

from imperial.

gaetandezeiraud avatar gaetandezeiraud commented on May 18, 2024

OK, thanks for the details!
I'll be back soon with a merger request for Keycloak support.

from imperial.

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.