Interactive brokers OAuth1.0 header fields problem.

Good day, I need help formatting header fields.
For Interactive brokers the OAuth requests require a header with the name “Authorization”. The authorization header must start with the string “OAuth”. Following "OAuth", it has to contain key/value pairs separated by comma. the key/value pairs include the consumer_key, timestamp, oauth_nonce, callback_URI... to name a few.
My problem is the initial format of the header.
I've used web options, to set the fields, but this does not send the data in the format Interactive Brokers want.
An example of how interactive brokers want the data is
authorization: OAuth realm="test_realm", oauth_callback="oob", oauth_consumer_key="TESTCONS", oauth_nonce="
3Xa0XhqFEoXbifYZUeflx6svQUDQsgB4",...
I have also used: field = matlab.net.http.HeaderField('Authorization','OAuth');
to set up the headerfields, but this does not allow for the space between OAuth and realm. in the header string.
Is there a way to format this using Matlab tools?

댓글 수: 3

Geoff Hayes
Geoff Hayes 2021년 10월 10일
편집: Geoff Hayes 2021년 10월 10일
@Ken Brown - please clarify what you mean by but this does not allow for the space between OAuth and realm. Are you observing an error? If so, what is it? It does seem kind of strange to have that space between the OAuth and realm. Are you sure that is correct? Or is the header called Oauth?
@Geoff Hayes I am using the reference material from Interactive Brokers (IB).
I am getting Error 400 Bad request. I dont think its the Data i am sending but the format.
Please see page 6 of the attachment as an example of the HTTP request required for IB.
@Ken Brown - I see from page six the following:
Authorization: OAuth oauth_callback="oob", \
oauth_consumer_key="TESTCONS", \ oauth_nonce="fcbc9c08d69ac269f7f1", \ oauth_signature="nHp...AA%3D%3D", \ oauth_signature_method="RSA-SHA256", \ oauth_timestamp="1473793701", \ realm="test_realm"
Could you create the authorization text as
authzText = 'OAuth oauth_callback="oob", oauth_consumer_key="TESTCONS", oauth_nonce="fcbc9c08d69ac269f7f1", oauth_signature="nHp...AA%3D%3D", oauth_signature_method="RSA-SHA256", oauth_timestamp="1473793701", realm="test_realm"'
and then create the header field as
field = matlab.net.http.HeaderField('Authorization', authzText);
where authzText is the properly formatted string that has the correct spaces between each field?

댓글을 달려면 로그인하십시오.

답변 (0개)

제품

릴리스

R2020a

질문:

2021년 10월 10일

댓글:

2021년 10월 18일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by