简体   繁体   中英

how to make a login activity in android studio that interacts with spring boot?

I have a spring boot application that serves information from a MySQL database to an android application. I'm having trouble with creating a secure login activity which interacts with spring boot and let's it know that it's a login activty so when the user is authorized, the app can make any api call it wants. The only way I've seen it done is to use spring boot's prebuilt login page. I want to create my own UI in the android application and just send the password and username as strings to be checked for authorization. I've made an unsecure workaround where the username and password are sent as a json file and they are processed by a request post method. This however does not solve my issue of only letting api calls work when the user is signed in. Is there a way to edit spring boot's log in page or like previously mentioned to send username and password in a secure manner? What is the best way to go about this?

The UI should be done with Android, not your backend. And your Spring boot backend (or whatever solution you choose) should provide a secured REST API to log.

The classic way is to get a token when you are logged (On a /login endpoint for exemple). Store it. And inject it in the HTTP Request when your access other endpoints (It is often sent as a Bearer Token or the Authorization HTTP header).

You will find a lot of documentation on this topic. Here are 2 pages I found which might help you:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM