'Declaration Public Event DeviceAuthenticationMessage As DeviceAuthenticationMessageEventHandler
'Usage Dim instance As TdConnection Dim handler As DeviceAuthenticationMessageEventHandler AddHandler instance.DeviceAuthenticationMessage, handler
public event DeviceAuthenticationMessageEventHandler DeviceAuthenticationMessage
public: event DeviceAuthenticationMessageEventHandler^ DeviceAuthenticationMessage
Event Data
The event handler receives an argument of type DeviceAuthenticationMessageEventArgs containing data related to this event. The following DeviceAuthenticationMessageEventArgs properties provide information specific to this event.
Property | Description |
---|---|
ExpiresIn | The lifetime in seconds of the UserCode. |
UserCode | The end-user verification code. |
VerificationUri | The end-user verification URI on the authorization server. |
VerificationUriComplete | The end-user verification URI that includes the UserCode (or other information with the same function as the UserCode) on the authorization server. |
Remarks
When TdConnectionStringBuilder.AuthenticationMechanism is set to "CODE", an application may register with this event if it wishes to display the end-user verification code and URI of the authorization server to the user. The application should prompt the user to visit the URI and confirm the verification code.
Example
The following example creates an instance of the TdConnection class with a DeviceAuthenticationMessage event handler. It displays the Device Code message to the user while establishing a session.
public void TestDeviceCodeFlow(TdConnectionStringBuilder builder) { builder.AuthenticationMechanism = "CODE"; builder.ConnectionTimeout = 60; using (TdConnection cn = new TdConnection(builder.ConnectionString)) { // Create the DeviceAuthenticationMessage event handler cn.DeviceAuthenticationMessage += new DeviceAuthenticationMessageEventHandler( (sender, e) => { // Provide the verification URI to the user. This requires user interaction. Console.WriteLine($"To proceed with Teradata authentication, use your web " + $"browser to visit the following URL: {e.VerificationUriComplete}"); }); // Open the connection. The DeviceAuthenticationMessage event handler will be called. // The Open method will return after the user has authenticated or when the connection times // out per ConnectionTimeout. cn.Open(); // do work cn.Close(); } }
Requirements
Product | Versions | Platforms |
---|---|---|
.NET | 6, 7 | Windows, Linux, MacOS |
.NET Framework | 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8 | Windows |
.NET Standard | 2.0 | Windows, Linux, MacOS |
See Also