Skip to first unread message

Joseph Parker

unread,
Apr 8, 2016, 12:33:29 PM4/8/16
to MIT App Inventor Forum

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

Taifun

unread,
Apr 8, 2016, 1:41:51 PM4/8/16
to MIT App Inventor Forum
it looks like you forgot the space after Basic?
Taifun

Trying to push the limits of App Inventor! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun. 

Joseph Parker

unread,
Apr 8, 2016, 1:43:12 PM4/8/16
to MIT App Inventor Forum
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.

Taifun

unread,
Apr 8, 2016, 1:46:41 PM4/8/16
to MIT App Inventor Forum
how does the corresponding curl command look like and what is the expected response?
Taifun

Joseph Parker

unread,
Apr 8, 2016, 1:59:54 PM4/8/16
to MIT App Inventor Forum
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.

Joseph Parker

unread,
Apr 8, 2016, 3:12:00 PM4/8/16
to MIT App Inventor Forum
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.....

Taifun

unread,
Apr 9, 2016, 12:07:31 PM4/9/16
to MIT App Inventor Forum
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?

Taifun

Joseph Parker

unread,
Apr 10, 2016, 7:01:08 PM4/10/16
to MIT App Inventor Forum
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 ...

Joseph Parker

unread,
Apr 10, 2016, 7:20:51 PM4/10/16
to MIT App Inventor Forum
Nah it didn't work with content type either.

Taifun

unread,
Apr 11, 2016, 11:15:57 AM4/11/16
to MIT App Inventor Forum
this discussion will continue in the following thread https://groups.google.com/d/msg/mitappinventortest/qP0hpSxN2Rw/Q0X3jtZ7AQAJ
Taifun
Reply all
Reply to author
Forward
0 new messages