4D Blog

Home Product 4D Netkit: Customizing OAuth 2.0 Connection Interface

4D Netkit: Customizing OAuth 2.0 Connection Interface

July 18, 2024

Product

Some of you may need to manage the display of the connection interface during an OAuth 2.0 connection for design or technical reasons. From 4D 20 R6, you can choose not to automatically open a web browser to display the connection interface but use the authenticateURI to display it where you like.

In this blog post, we’ll walk through an example of opening the Microsoft login interface within a web area.

HDI Netkit BrowserAutoOpen false

Example

In the example below, we’ll see how to open the Microsoft login interface in a web area. For that, you need to create a form with a web area called “WAConnection”

First, let’s create an OAuth2GetToken method to manage the display of the connection interface in the web area and wait for the token to be received. As this method will be called in a worker, we use the CALL FORM command to display the information in the current form:

#DECLARE($credential : Object; $CurrentWindows : Integer)

var $OAuth2:=cs.NetKit.OAuth2Provider.new($credential)

// Display the connection page in the web area "WAConnection"
CALL FORM($CurrentWindows; Formula(WA OPEN URL(*; "WAConnection"; $1)); $OAuth2.authenticateURI)

// Wait for the token and save it in the Form.token attribute
CALL FORM($CurrentWindows; Formula(Form.token:=$1); $OAuth2.getToken())

Then you have to call this method in a worker with browserAutoOpen attribute to false in the credential parameters:

var $credential:={}
$credential.name:="Microsoft"
$credential.permission:="signedIn"
$credential.clientId:="7008ebf5-xxx"
$credential.redirectURI:="http://127.0.0.1:50993/authorize/"
$credential.scope:="https://graph.microsoft.com/.default"
$credential.accessType:="offline"
$credential.prompt:="select_account"
	
// The display of the connection interface is managed by the developer.
// The browser is not automatically opened
$credential.browserAutoOpen:=False
	
// Call of the OAuth2GetToken method
CALL WORKER("OAuth2Worker"; Formula(OAuth2GetToken($1; $2)); $credential; Current form window)

So, if you open your form and execute the code above, the connection interface will be displayed in your web area, and 4D webserver will wait for the token:

Conclusion

By using this feature, developers can bypass the automatic web browser opening and gain control over the presentation of the connection interface. This flexibility allows for a more integrated user experience tailored to the specific needs of your application.

Discuss

Tags 20 R6, 21, 4D NetKit, OAuth 2.0

Latest related posts

  • February 3, 2026

    4D Write Pro – Adding a margin automatically when bullets are set using standard actions

  • January 22, 2026

    Transform Static Documents into Actionable Knowledge with AIKit

  • January 22, 2026

    Deploy Fluent UI effortlessly in your 4D applications

Fabrice Mainguené
Fabrice Mainguené
• Product Owner •Fabrice Mainguené joined 4D Program team in November, 2016. As a Product Owner, he is in charge of writing the user stories then translating it to functional specifications. His role is also to make sure that the feature implementation delivered is meeting the customer need.After obtaining a Bachelor degree in Computer Science at CNAM, Fabrice joined a small software publishing company as a Windev developer. Then he worked for different companies in industry and trade areas as a Windev and web developer as well as technical advisor on new features.
  • Deutsch
  • Français
  • English
  • Português
  • Čeština
  • Español
  • Italiano
  • 日本語

Categories

Browse categories

  • AI
  • Release infos
  • 4D View Pro
  • 4D Write Pro
  • Email, Microsoft 365, Gmail
  • Development Mode
  • 4D Language
  • ORDA
  • User Interface / GUI
  • 4D Qodly Pro
  • Server
  • Maintenance
  • Deployment
  • 4D Tutorials
  • Generic
  • 4D Summit sessions and other online videos

Tags

4D AIKit 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 21 21 R2 Administration AI Artificial Intelligence Build application CI/CD Class Client/Server Code editor Collections Formula Google Listbox Logs Mail Microsoft 365 Network Objects OpenAI ORDA PDF Pictures Preemptive Programming REST Scalability Security Session Source control Speed Spreadsheet Tutorial UI User Experience vscode Web Word processor

Tags

4D AIKit 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 21 21 R2 Administration AI Artificial Intelligence Build application CI/CD Class Client/Server Code editor Collections Formula Google Listbox Logs Mail Microsoft 365 Network Objects OpenAI ORDA PDF Pictures Preemptive Programming REST Scalability Security Session Source control Speed Spreadsheet Tutorial UI User Experience vscode Web Word processor
Subscribe to 4D Newsletter

© 2026 4D SAS - All rights reserved
Terms & Conditions | Legal Notices | Data Policy | Cookie Policy | Contact us | Write for us


Subscribe to 4D Newsletter

* Your privacy is very important to us. Please click here to view our Policy

Contact us

Got a question, suggestion or just want to get in touch with the 4D bloggers? Drop us a line!

* Your privacy is very important to us. Please click here to view our Policy