delphi-rest-client-api icon indicating copy to clipboard operation
delphi-rest-client-api copied to clipboard

Authorization

Open danilobicas-unoeste opened this issue 6 years ago • 1 comments

Hi. And about Authorization with token (bearer token)? How I implement this to send to the server?

tk's

Danilo

danilobicas-unoeste avatar Mar 15 '18 21:03 danilobicas-unoeste

You should set the correct HTTP-header before sending the reqeust...

Ex. based on 'DelphiRestDemo' (uFrm_PersonList.TFrm_PersonList.RefreshList)

without header:

  vResponse := Dm.RestClient.Resource(CONTEXT_PATH + 'persons')
                            .Accept(RestUtils.MediaType_Json)
                            .Get<TList<TPerson>>();

with header:

  vResponse := Dm.RestClient.Resource(CONTEXT_PATH + 'persons')
                            .Accept(RestUtils.MediaType_Json)
                            .Header('Authorization','Bearer <token>')
                            .Get<TList<TPerson>>();

ronaldhoek avatar Mar 16 '18 07:03 ronaldhoek