Salesforce

How to use HTTP authentication with the HTTP client?

« Go Back

Information

 
TitleHow to use HTTP authentication with the HTTP client?
URL NameHow-to-use-HTTP-authentication-with-the-HTTP-client
Article Number000140307
EnvironmentProduct: OpenEdge
Version: 11.6, 11.7, 12.x
OS: All Supported Platforms
Other: OpenEdge HttpClient
Question/Problem Description

These examples show how to use HTTP authentication with the HTTP client.

The HTTP client uses a OpenEdge.Net.HTTP.Credentials object to provide user details for a request. This object contains just three properties:

/** The domain (or realm) to which the user belongs */
DEFINE PUBLIC PROPERTY Domain AS CHARACTER NO-UNDO
    GET.
    SET.

/** The user name */
DEFINE PUBLIC PROPERTY UserName AS CHARACTER NO-UNDO
    GET.
    SET.

/** The user's password for this domain */
DEFINE PUBLIC PROPERTY Password AS CHARACTER NO-UNDO
    GET.
    SET.

 
Steps to Reproduce
Clarifying Information
Error Message
Defect Number
Enhancement Number
Cause
Resolution

There are two mechanisms provided for specifying credentials on a request: pre-emptive and callback.

Preemptive authentication

Pre-emptive authentication is used when the the developer knows that credentials are required before the request is made.

Credentials can be added to a request using the UsingBasicAuthentication()UsingDigestAuthentication() and UsingCredentials() methods. The first two methods will result result in a Authorization header to be added to the request; the latter will hold the credentials until they're asked for by the server. Credentials are added in response to a 401/Unauthorized status code, and a second request is made.

Callbacks

Callbacks allow a developer to provide a place to provide credentials if they are requested by the server and have not yet been provided. Callbacks are triggered by a 401/Unauthorized response status code and result in a second request with credentials.

Callbacks are added to a request via the AuthCallback() method on the RequestBuilder.

Callbacks can be in classes or procedures and must implement the following interface. If procedures are used, an internal procedure named AuthFilter_HttpCredentialRequestHandler must exist with the signature .

INTERFACE OpenEdge.Net.HTTP.Filter.Auth.IAuthFilterEventHandler:
    /** Event handler for the HttpCredentialRequest event.
    
    @param Object The filter object that publishes the event.
    @param AuthenticationRequestEventArgs The event args for the event */
    METHOD PUBLIC VOID AuthFilter_HttpCredentialRequestHandler(
                                INPUT poSender      AS Object,
                                INPUT poEventArgs AS AuthenticationRequestEventArgs).    

END INTERFACE.
 

Examples

ProgramPurpose
basic_preemptive.pIllustrates adding credentials before making a request. The server expects credentials using the basic authentication method per per http://tools.ietf.org/html/rfc2617
basic_callback_proc.pIllustrates adding credentials via a callback procedure. The server expects credentials using the basic authentication method per per http://tools.ietf.org/html/rfc2617
basic_callback_obj.pIllustrates adding credentials via a callback object. The server expects credentials using the basic authentication method per per http://tools.ietf.org/html/rfc2617
SimpleAuthCallback.clsClass implementing IAuthFilterEventHandler that is used as a callback handler by basic_callback_obj.p
Workaround

 
Notes
References to Other Documentation:

Progress Article(s):
 Is there an HTTP client for OpenEdge?
 OpenEdge.Net.pl is missing from PROPATH

External Sources:
HTTP Authentication: Basic and Digest Access Authentication Spec:
http://tools.ietf.org/html/rfc2617
 
Keyword Phrase
Last Modified Date8/20/2025 11:52 AM

Powered by