Quantcast

Authentication header in function urlread

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Authentication header in function urlread

babelproofreader
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?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Authentication header in function urlread

Mike Miller-4
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

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Loading...