help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Authentication header in function urlread


From: Mike Miller
Subject: Re: Authentication header in function urlread
Date: Mon, 24 Apr 2017 08:20:58 -0700
User-agent: NeoMutt/20170113 (1.7.2)

On Mon, Apr 24, 2017 at 06:05:11 -0700, babelproofreader wrote:
> I would like to access a web api that requires an authentication/bearer token
> in an authorization header. The website gives a curl example of
> 
> curl -H "Authorization: Bearer 12345678900987654321-abc34135acde13f13530"
> https://api-fxtrade.oanda.com/v1/accounts
> 
> How would I use this as input arguments to the urlread function?

The urlread function does not support custom HTTP headers.

The way to do this in Matlab would be with the matlab.net.http package,
which Octave does not support yet.

To do this in Octave now, the best options would be to use the Java or
Python (in development) interfaces, like this

    h = javaObject ("java.net.URL", "https://api-fxtrade...";);
    c = h.openConnection ();
    c.setRequestProperty("Authorization", ...);
    ...

or this

    c = py.httplib.HTTPSConnection ("api-fxtrade.oanda.com");
    h = py.dict (pyargs ("Authorization", "..."));
    c.request ("GET", "/v1/accounts", "", h);
    r = c.getresponse ();
    ...

(not fully working examples).

Or shell out to the curl program.

-- 
mike



reply via email to

[Prev in Thread] Current Thread [Next in Thread]