In my application I'm fetching data in JSON format from a web service (Yii PHP site acting as a REST service) that requires authentication.
HttpPost post = new HttpPost(login_url);
UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(name, pass);
post.addHeader(BasicScheme.authenticate(credentials, "UTF-8", false));
All methods are executed by a single instance of DefaultHttpClient
with use of subclassed AsyncTask
.
Authentication works fine, but fetching data from another URL gets authentication fail (custom message in internal service format).
HttpPost post = new HttpPost(service_url);
client.execute(post);
Trying to figure out what's the problem I've checked for answers and tested some of them.
I've managed to establish that CookieStorage
in DefaultHttpClient
instance actually receives and holds Cookies, after first call there are two, one of them is PHPSESSID
and it's not expired. Second one appears to be some encoded stuff and it's expiration date seems to be creation time, because it's already expired when I receive it.
If you have any thoughts on this issue, please comment. I've hit a deadend with searching and trying out things that worked for other people.
It turned out there was no problem with my code, but the service had an error. Thanks for viewing this question and to @Joël for formatting this for me. Kudos
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加