Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Imperial Beta release: Google completion handler not called #115

Closed
mynona opened this issue Dec 26, 2024 · 7 comments · Fixed by #116
Closed

Imperial Beta release: Google completion handler not called #115

mynona opened this issue Dec 26, 2024 · 7 comments · Fixed by #116
Assignees
Labels

Comments

@mynona
Copy link

mynona commented Dec 26, 2024

There is an issue with the Google login flow as the completion handler doesn't get called.

func boot(routes: RoutesBuilder) throws {

      let googleCallbackURL = try getEnvironmentVariable(for: "GOOGLE_CALLBACK_URL")

      try routes.oAuth(
         from: Google.self,
         authenticate: "auth/google/",
         callback: googleCallbackURL,
         scope: ["profile", "email"],
         completion: processGoogleLogin
      )
   }

The routes seem to be correctly registered, but when I call the routes via postman I get a 404.
I would expect a 400 Bad Request as the route is called without code

@mynona mynona changed the title Imperial Beta release Imperial Beta release: Google completion handler not called Dec 26, 2024
@mynona
Copy link
Author

mynona commented Dec 26, 2024

@fpseverino

@fpseverino fpseverino self-assigned this Dec 26, 2024
@fpseverino
Copy link
Member

fpseverino commented Dec 26, 2024

Trying it myself it seems like GOOGLE_CALLBACK_URL should contain only the path and not the full URL (e.g. oauth/google/ and not http://localhost:8080/oauth/google).

With the full URL I get a 404 when querying http://localhost:8080/oauth/google and a 400 when querying http://localhost:8080/http://localhost:8080/oauth/google.
Giving it only the path I get a 400 when querying http://localhost:8080/oauth/google (as it should be).

@fpseverino
Copy link
Member

In the latest beta we switched from custom path components handling to RoutingKit, so it must be that.

@fpseverino
Copy link
Member

On the bright side you should now not need the environment variable anymore as you can pass the path directly to it and it will be valid for development and production.

I think this is why the Kodeco book used environmental variables, and not for security reasons, but I'm not 100% sure.

@mynona
Copy link
Author

mynona commented Dec 26, 2024

Looks as Google has a different opinion on that:
Bildschirmfoto 2024-12-26 um 20 30 49

@mynona
Copy link
Author

mynona commented Dec 26, 2024

Seems Google requires the full URL. Will it be possible to update Imperial that it will follow the same logic as before the beta release?

Thank you for your support!

@mynona
Copy link
Author

mynona commented Dec 26, 2024

Google does not allow adding URIs without https: or http:

Bildschirmfoto 2024-12-26 um 20 45 38

@fpseverino fpseverino added the bug label Dec 27, 2024
fpseverino added a commit that referenced this issue Jan 1, 2025
* Adopt VaporTesting

* Try fix for #115

* Make the linter happy

* Use `pathSegments` also for `authURL`

* Update GoogleJWT audience claim to use `accessTokenURL`

* Remove redundant test

* Update Imperial version in README to `2.0.0-beta.2`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging a pull request may close this issue.

2 participants