Main Content


Register custom authentication callback function to OSLC client

Since R2021b



    setCustomLoginProvider(myClient,authenticationFunction) registers a custom authentication callback function, authenticationFunction, for the OSLC client object myClient. You can use this function to authenticate an OSLC client object on networks that require advanced authentication that the default authentication process does not support.


    The custom authentication callback function should take this form:

    function [success,cookies] = myCustomLoginProvider(server,options)
    % Provide your implementation here
    The custom authentication function should return two arguments: success status and the authenticated cookies received from the server as a object.


    collapse all

    This example shows how to authenticate an OSLC client by using a custom authentication function and custom HTTP options.

    Create the OSLC client.

    myClient = oslc.Client;

    Set the server URL, service root, and catalog path for your service provider.


    Create and enter the user credentials by using the class with a basic object.

    creds ='Username','jdoe','Password', ...

    Create custom HTTP options by using the class constructor. Set the Credentials property and certificate information for the custom HTTP options.

    opts ='Credentials',creds, ...
        'VerifyServerName', false, 'CertificateFilename', '')
    opts = 
      HTTPOptions with properties:
               MaxRedirects: 20
             ConnectTimeout: 10
                   UseProxy: 1
                   ProxyURI: []
               Authenticate: 1
                Credentials: [1×1]
         UseProgressMonitor: 0
                SavePayload: 0
            ConvertResponse: 1
             DecodeResponse: 1
         ProgressMonitorFcn: []
        CertificateFilename: ""
           VerifyServerName: 0
                DataTimeout: Inf
            ResponseTimeout: Inf
           KeepAliveTimeout: Inf

    Specify the custom HTTP options to authenticate the OSLC client myClient.


    Create a custom authentication callback function called myCustomLoginProvider.

    function [success,cookies] = myCustomLoginProvider(server,options)

    Register the custom authentication callback function with the OSLC client object.


    Authenticate the OSLC client object.


    Input Arguments

    collapse all

    OSLC client, specified as an oslc.Client object.

    Custom authentication callback function name, specified as a character vector.

    Example: 'myCustomLoginProvider'


    • If your authentication process requires a particular set of HTTP options, you can either:

      • Construct a object and assign it to your OSLC client by using setHttpOptions, which passes the HTTP options to your custom authentication callback function.

      • Construct the HTTP options internally in your custom authentication callback function.

    • If you want to preconfigure the login process with credentials or use a particular authentication scheme, you can create a object and include it with a object that you assign to the OSLC client object. For more information, see Server Authentication.


      Depending on the authentication method used by your server, your custom authentication callback function might also have to satisfy authentication requirements. For example, you might have to mimic the form-based authentication required by your authentication server.

    • You can unregister all callbacks from an OSLC client object myClient by entering:


    Version History

    Introduced in R2021b