Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

matlab.net.http.field.AuthorizationField class

Package: matlab.net.http.field
Superclasses: matlab.net.http.HeaderField

HTTP Authorization or Proxy-Authorization header field

Description

An AuthorizationField object contains credentials in a request message in response to a challenge from a server in an AuthenticateField. The credentials are in the form of an AuthInfo object. For a description of these fields, see RFC 7235 section 4.2 and section 4.4.

MATLAB® automatically creates this field when:

  • HTTPOptions.Authenticate property is true (default) in a request message.

  • You have specified appropriate credentials in the HTTPOptions.Credentials property.

  • MATLAB supports the authentication scheme requested by the server.

You create this field explicitly when you disable automatic authentication or implement an unsupported authentication protocol. If you create this field explicitly, then set the Value property to a valid authorization string or an AuthInfo object.

To see the AuthorizationField that was sent to the server for automatic authentication, examine the completed request or history arguments returned by the RequestMessage.send method.

Construction

example

obj = matlab.net.http.field.AuthorizationField(name,value) creates an authorization header field with the Name property set to name and the Value property set to value. Create this field if you disabled automatic authentication or to implement an unsupported authentication protocol.

Properties

expand all

Header field name, specified as 'Authorization' or 'Proxy-Authorization'.

Authorization, specified as a valid authorization string or a matlab.net.http.AuthInfo object.

Methods

convert

Value of AuthorizationField as vector of AuthInfo objects.

There is only one AuthInfo object in an AuthorizationField. If you pass in a vector of AuthorizationField objects, convert returns an equal-size vector of AuthInfo objects. The parameters in AuthInfo correspond to parameters of the credentials in the AuthorizationField. This set of parameters varies depending on the AuthInfo.Scheme property, which is the first token in the field.

Attributes

Sealedtrue

Examples

expand all

import matlab.net.http.*
creds = Credentials('Username','MyName','Password','MyPassword');
options = HTTPOptions('Credentials', creds);
[response, request] = RequestMessage().send('http://myhost.com',options);
authorizationField = request.getFields('Authorization');
authInfo = authorizationField.convert;
disp(string(authInfo));
Was this topic helpful?