I am building an android app that is supposed to edit documents it can get from a remote server. However, to do so i need the user to log in. This should happen like this:
User types in userId and password, POST is sent with this body:
{
"username": "normal_username",
"password": "normal_password"
}
and when i do so in postman the response body looks like this { "username": "normal_username", "token": "lotsandlotsofnumbersandletters" }
I want to retrieve this token, but i dont know how to do so in android, are there any external libraries that could make this easier for me perhaps?
Since the response body is JSON, you need to parse it. Use a library such as GSON to do so then you can easily grab the value of the "token"
key.
You also might want to look at a library that wraps the entire REST API. Retrofit from Square is one of the most popular libraries that does this.