2017년 1월 15일 일요일

Basic Authentication in a web request


I've complete the stock info tutorial which includes a web request and that works no problem.

I've moved on to a new app which includes web requests but these require basic authorization in the request header.

I thought it should be fairly straightforward:
1.  Set the URL and params
2.  Set the RequestHeader to the list (("Authorization:", "Basic <mytoken"))

Doesn't work - it says I need an authorization token etc.

I have verified the correct authorization token using postman and curl to submit the same request successfully so I'm assuming I'm doing something wrong in App Inventory.

Any ideas?

Here is the block
--
it looks like you forgot the space after Basic?

--
No - I should have mentioned that there is a space in the MyToken.  I've now added the space in the join to make it more obvious.....

Good catch.

--
how does the corresponding curl command look like and what is the expected response?

--
simply: curl -L -u <token> -k <url>
where token and url are identical to the contents of the globals in AI2

Result is the xml document with a list of text and some meta data.

--
after some further investigation I can also use:
https://<token>@<domain>.<path> directly through my browser or curl or postman.

However, when I build this identical string in AI2 it still fails with the same error - need token or username password.....

--
for the webviewer this does not work for all Android versions, see also https://puravidaapps.com/snippets.php#2authurl

authorization generally works, see also https://puravidaapps.com/dropbox.php
but I did not try basic authorization up to now with the web component...
probably you also have to set a Content-Type?

--
That would explain it add I am testing with Samsung galaxy ... I'll try adding content-type and let you know.  If not I'll report a bug I guess ...

--
Nah it didn't work with content type either.

--
this discussion will continue in the following thread: Bug Report: Basic Authentication does not work (or at least not on all platforms

-- 

댓글 없음:

댓글 쓰기