%% Provide Authentication
% This example shows how to set the authentication scheme in a request message.
%% Specify Image URL

import matlab.net.*;
import matlab.net.http.*;

httpsUrl = "https://requestserver.mathworks.com";
uri = URI(strcat(httpsUrl, "/assets/computerVision.jpg?authenticate=digest"));

%
%% Set Credentials
% Set the authentication scheme to Digest and provide login credentials.

cred = Credentials("Scheme", "Digest", "Username", "testName", "Password", "testPass");
options = HTTPOptions;
options.Credentials = cred;
options.Authenticate = false;
req = RequestMessage('GET');
response = req.send(uri, options);
authenticateField = response.getFields("WWW-Authenticate");
disp(authenticateField)

% Copyright 2020 The MathWorks, Inc.