autherization headers with Bangle.http

Posted on
  • Is there a way to pass an autherization header using the Bangle.http option?

    I've tested passing this in as part of my POST, using the header option and also attempted to pass login creds via the URL I send the POST to but it isn't sent across.

    I can pass the data via the Body as an alternative but wanted to check if autherization was supported in some way that I wasn't trying or if it's never passed with the request being sent out.

  • You should be able to pass any kind of authorization in the headers of the options when making the HTTP call.

    You can for example check the sources of the android integration here:
    https://github.com/espruino/BangleApps/blob/master/apps/android/boot.js#L310-L328

    So basically you should be able to make a POST call with authorization headers like this:

    Bangle.http(
        'http://example.com',
        {
            method: 'POST',
            headers: {Authorization: 'Bearer <your JWT>'}
        }
    )
    

    (maybe you typed header instead of headers or some other typo?)

  • Thanks @devsnd. Didn't see your response until now.

    Think I was botching the syntax initially but your post has made everything clear.

    Thanks for the help!

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

autherization headers with Bangle.http

Posted by Avatar for Guptilious @Guptilious

Actions