Thanks! I made all changes, but this didn’t fix the issue, sadly.
My oauth2/authorization/twitch endpoint is working fine!
But for /oauth2/code/twitch its Could not navigate to 'oauth2/code/twitch'
This is my LoginView:
@Route("/")
@AnonymousAllowed
public class LoginView extends VerticalLayout {
public LoginView() {
Anchor login = new Anchor("oauth2/authorization/twitch", "Login with Twitch");
login.getElement().setAttribute("theme", "primary");
login.setRouterIgnore(true);
add(login);
}
}
OK, now I see you have a custom login page at the / path, so my suggestion of setting /oauth2/authorization/twitch does not make sense with your setup.
Related to Marco’s observation, is there a reason your login view is at the root (@Route("/"))? Typically you’d have your default view like the Dashboard at the root ("") and the login view at "login".
And also the navigation error message is different between the first and the last post
It was Could not navigate to ‘login/oauth2/code/twitch but now it is Could not navigate to 'oauth2/code/twitch'.
Is this only a typo or did you change something else in the configuration?
For the redirect URI I would also suggest using {baseUrl}/login/oauth2/code/twitch
I’ve been experimenting a bit, yes. That’s why there are differences in the error.
So maybe my approach is wrong, but I’ll try to explain my plan, maybe it’s just that it can’t work at all.
Basically, I want the main page (/) to be a general website with a login button above it.
After logging in, you should be taken to the dashboard (/dashboard).
This would be my main page / “login” page now:
@Route("")
@AnonymousAllowed
public class LoginView extends VerticalLayout {
public LoginView() {
// Login-Link startet OAuth2-Flow bei Twitch - absolute URL, Vaadin Router ignorieren
Anchor login = new Anchor("/oauth2/authorization/twitch", "Login with Twitch");
login.getElement().setAttribute("theme", "primary");
login.setRouterIgnore(true);
add(login);
}
}
This is my current SecurityConfig, where i tested some different methods, i first tried the the custom oauth2Login and also the default oauth2Login, but same result