Maintaining session in android ( application stay authenticated on the server side)

后端 未结 5 1679
太阳男子
太阳男子 2020-11-29 16:29

I am building a login application in android in which i am hitting a url(with username and password) upto that part it works fine but after that whenever I am hitting a url(

5条回答
  •  盖世英雄少女心
    2020-11-29 17:34

    My problem was that i login first and saved the returned session in userpreferences. After that the POST call to set a record said

    "Error ,Cannot authenticate the User"

    So i added post.setHeader("oAuth-Token", UserPreferences.ACCESS_TOKEN); the whole thing looks like this.

    HttpPost post=new HttpPost(URL );  
    post.setHeader("oAuth-Token", UserPreferences.ACCESS_TOKEN);    
    

    . . and It solved the problem.

提交回复
热议问题