4D NetKit just made redirecting users after OAuth 2.0 authentication easier with 4D 21. The OAuth2Provider class in 4D NetKit now allows real URLs for authenticationPage and authenticationErrorPage. This means you now have more redirection options after authentication, like a Qodly pages or HTTP Handlers. Whether the authentication succeeds or fails, you stay in control of the user experience with smooth, flexible redirection options.
What changed?
These two attributes were already part of the NetKit.OAuth2Provider class, but they previously required a relative URL. Now, you can pass a full URL to either field, pointing directly to a custom Qodly page or any web destination of your choice.
var $credential:={}
$credential.name:="Microsoft"
$credential.permission:="signedIn"
$credential.clientId:="xxxxx"
$credential.redirectURI:="http://127.0.0.1:50993/authorize/"
$credential.scope:="https://graph.microsoft.com/.default"
$credential.browserAutoOpen:=False
// If authentication succeeds, redirect the user to the Calendar page
$credential.authenticationPage:="http://localhost/$lib/renderer/?w=Calendar"
// If authentication fails, redirect the user to the Connect (login) page
$credential.authenticationErrorPage:="http://localhost/$lib/renderer/?w=Connect"
// Create new OAuth2 object
return cs.NetKit.OAuth2Provider.new($credential)
Redirecting to custom URLs simplifies the overall authentication flow. Instead of building extra logic to navigate users after a successful login or failed attempt, you can now:
- Send users directly to the next page in your app
- Handle authentication errors gracefully with a dedicated error page
Conclusion
By letting the OAuth2 process take care of redirection, you reduce complexity in your code and avoid unnecessary intermediate steps. Just configure your URLs, and 4D will handle the rest.
