%% Provide Credentials
% This example shows how to pass user name and password to a Web server.

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

httpsUrl = 'https://requestserver.mathworks.com';
cred = Credentials('Scheme', 'Digest', 'Username', 'testName', 'Password', 'testPass');
uri = URI(strcat(httpsUrl, '/assets/computerVision.jpg?authenticate=digest'));
options = HTTPOptions;
options.Credentials = cred;
req = RequestMessage('GET');
[~, completedRequest, ~] = req.send(uri, options);
authorizationField = completedRequest.getFields("Authorization");
disp(authorizationField)

% Copyright 2020 The MathWorks, Inc.