登录 - android登陆的token问题
阿神
阿神 2017-04-17 17:29:09
0
4
640

在用户登陆的时候,服务器会返回一个Token信息给我,说是每个请求都要携带Token,然后我要怎么处理这个Token呢?例如我用的okhttp,我要怎么携带这个token给服务器呢,token过期要怎么处理,没接触过这方面的东西,不知道要怎么做,,,

阿神
阿神

闭关修行中......

reply all(4)
黄舟

Persistent token. This is how I implemented it: when logging in, the token will come back, and I saved it locally. Each time the interface is called, the token is returned. If the token expires, the server will return a status message, and I will jump back to the login interface and request the token again. above! Hope it helps you

Ty80

This is what I did. By default, I go directly to get the content and judge the result. If not logged in, call the login method (the token will be returned after success) and then grab the web page, because some tokens themselves are also time-sensitive, local transformation may not be reliable.

黄舟

1. In your http request header, put the token in and check the knowledge about http.
2. The token will expire, as mentioned above, so how to deal with it once it expires needs to be related to the server. Good deal

大家讲道理

First negotiate with the service where to put the token 'url, head, body? Decide on the location and insert interpra' in okhttp to make global changes

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template