Problems with creating Login page in MIT APP Inventor using a Google App script connected to a Google Sheet

Hello,

I've been able to create my first App Script which is able to add rows to a google sheet and, most important, get data from that sheet in order to "Login".
So the Login form is working.

Unfortunately, I'm experiencing problems creating the right blocks in MIT APP Inventor: basically it doesn't read the APP, and it's "logging in" with any credential.

I'm adding here after the .aia file of the project, and the two scripts of the Google Apps Script, hoping someone can help me out.

Thanks a lot, best

Try_Login.aia (4.0 KB)
index.html.txt (6.3 KB)
Codice.gs.txt (1.2 KB)

Why the UI from the web app ?

You can provide all the UI in your AI2 app, and have your google apps script handle the interaction with the google sheet...

I don't know how to do it... Thought the toughest part was to have the google app working, but now I don't know how to build the blocks in the AI2... Can't find a video instruction nor a post working for me either...

Perhaps:

as an example...

Thanks.

I'm trying to use the suggested script, but it gives me an error at line 7 (image attached).
Can you help me solving it?

Thanks a lot.

I presume you have run the script in the script editor ?

The script is expecting a parameter to be provided for fn - either getusers, register or login. This is usually provided by the AppInventor app.

You are right!

Completing the AI2 blocks, the apps script does work, BUT.... something strange happens:

  • the "registration" procedure works well, but I see in the google spreadsheet that the password saved is different from the one chosen in the AI2 (which then works, in the Login... how is possible?);
  • the "reset password" procedure also works, but again, the password sent by e-mail is different then the one that appers in the spreadsheet (could this be something like a code?)
  • the "Login" procedure works just after the previous 2... otherwise, if I add first in the spreadsheet username and password, the AI2 doesn't recognise it (error: "login failed...please try again").

Magic! No, the user password is converted the a one way hash, this is then used to test the real password. Most online services use this type of security.

Same magic as above !

You have to use the app to add users, to ensure the correct "magic" is applied to the password.

This protects the users from the developer!!!

e.g. Google (say...) they do not know your google account password, because it is hashed....

:smiley:

Makes sense! Thanks a lot, very much appreciated