How can i send headers for authentication?

Solved!
Posted in Designs by René Montes de Oca Mon May 09 2016 21:22:31 GMT+0000 (Coordinated Universal Time)·9·Viewed 840 times

I need to submit a custom header (X-Auth-Token) with my token as the value. How can i achieve this with aping?
May 9, 2016

I'm not sure what you wanna do. Could you submit a jsfiddle or something else?

May 9, 2016

Each request i submit to the REST API endpoint i must send additional headers, in this case:

  • X-Auth-Token: my-token

I thought that i could add an additional parameter on the directory like this:

<aping
        template-url="template.html"
        aping-jsonloader="[{ 'path': 'http://api.football-data.org/v1/soccerseasons'}]"
        headers="X-Auth-Token: my-token">
</aping>

I have no idea if it will work or if i should write additional code on the controller to add the headers.

Thank you very much for your quick response

May 9, 2016

apiNG's first idea is just to GET data. if you wanna POST data, then you need do this in a controller of your template

May 9, 2016

here is a list of all parameters of the built-in plugin "jsonloader": https://aping.readme.io/docs/usage#built-in-plugin-json-loader

May 9, 2016

Thank you Jonathan, however i am not trying to POST data, i am talking about a GET request with custom headers.

I will give a look to source and try to figure it out.

May 11, 2016

Okay. You could send me a pull request for apiNG (https://github.com/JohnnyTheTank/apiNG) when you are done ;)

June 26, 2016

Hello René Montes de Oca,

now I added this feature. You can use it with apiNG version 1.4.x and higher:

<aping
        template-url="template.html"
        aping-jsonloader="[{ 'path': 'http://api.football-data.org/v1/soccerseasons', 'xAuthToken':'<YOUR_XAUTHTOKEN>'}]">
</aping>

But you could also use the new football-data.org plugin for apiNG: https://github.com/JohnnyTheTank/apiNG-plugin-footballdata

demo: http://plnkr.co/edit/a8Uj8V


marked this as solved
June 26, 2016

Awesome, thanks for the update Jonathan.

I will give it a try.

Sep 4, 2016

René Montes de Oca: does it work for you?

Markdown is allowed