Android app custom web service authentication using HttpPost does not stick

Dejanarchos

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.

Dejanarchos

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]

編集
0

コメントを追加

0

関連記事

分類Dev

Custom web app authentication with WildFly

分類Dev

Unable to send HttpPost request using Android app

分類Dev

Design for Facebook authentication in an iOS app that also accesses a secured web service

分類Dev

Client part of the Digest Authentication using PHP POST to Web Service

分類Dev

Android, does foreground service keep app alive?

分類Dev

Mobile app Web API authentication

分類Dev

Using Azure Active Directory authentication in ASP.NET Core 2.0 from Web App to Web API

分類Dev

Custom authentication for SOAP using JavaEE

分類Dev

Authentication Process is not triggered when using IBM App ID in IBM Cloud Kubernetes Service

分類Dev

Using a custom AndroidManifest on a Qt app for Android without using qmake?

分類Dev

Facebook authentication via android app

分類Dev

using HttpPost annotation? Fix so it does not break page

分類Dev

Choosing web service for iphone app

分類Dev

Azure Web App logout from AAD Authentication

分類Dev

Class translator does not exist when using app()->setLocale() in app service provider

分類Dev

Using Firebase Authentication with new @App protocol

分類Dev

Azure App Service Authentication - 302 when trying to GET /.auth/me

分類Dev

Trouble getting ClaimsPrincipal populated when using EasyAuth to authenticate against AAD on Azure App Service in a Asp.Net Core web app

分類Dev

HttpPost not working in Android

分類Dev

Azure Managed Service Identity option disabled on Linux Web app service

分類Dev

How to configure a custom domain for a containerized web app?

分類Dev

How to properly use express-gateway for authentication of a web app?

分類Dev

Android app that emulates browser to run web app

分類Dev

Android app that emulates browser to run web app

分類Dev

Disabling dependency logging for Application insights on Azure app service (Web app)

分類Dev

Custom Authentication using legacy user table in Asp.Net Core

分類Dev

Why does consuming a RESTful web service (using javax.ws.rs.* and Jsersey) work in unit test but not when submitted to Spark?

分類Dev

How to speed up the web service in Android?

分類Dev

How to stop Android service when app is closed

Related 関連記事

  1. 1

    Custom web app authentication with WildFly

  2. 2

    Unable to send HttpPost request using Android app

  3. 3

    Design for Facebook authentication in an iOS app that also accesses a secured web service

  4. 4

    Client part of the Digest Authentication using PHP POST to Web Service

  5. 5

    Android, does foreground service keep app alive?

  6. 6

    Mobile app Web API authentication

  7. 7

    Using Azure Active Directory authentication in ASP.NET Core 2.0 from Web App to Web API

  8. 8

    Custom authentication for SOAP using JavaEE

  9. 9

    Authentication Process is not triggered when using IBM App ID in IBM Cloud Kubernetes Service

  10. 10

    Using a custom AndroidManifest on a Qt app for Android without using qmake?

  11. 11

    Facebook authentication via android app

  12. 12

    using HttpPost annotation? Fix so it does not break page

  13. 13

    Choosing web service for iphone app

  14. 14

    Azure Web App logout from AAD Authentication

  15. 15

    Class translator does not exist when using app()->setLocale() in app service provider

  16. 16

    Using Firebase Authentication with new @App protocol

  17. 17

    Azure App Service Authentication - 302 when trying to GET /.auth/me

  18. 18

    Trouble getting ClaimsPrincipal populated when using EasyAuth to authenticate against AAD on Azure App Service in a Asp.Net Core web app

  19. 19

    HttpPost not working in Android

  20. 20

    Azure Managed Service Identity option disabled on Linux Web app service

  21. 21

    How to configure a custom domain for a containerized web app?

  22. 22

    How to properly use express-gateway for authentication of a web app?

  23. 23

    Android app that emulates browser to run web app

  24. 24

    Android app that emulates browser to run web app

  25. 25

    Disabling dependency logging for Application insights on Azure app service (Web app)

  26. 26

    Custom Authentication using legacy user table in Asp.Net Core

  27. 27

    Why does consuming a RESTful web service (using javax.ws.rs.* and Jsersey) work in unit test but not when submitted to Spark?

  28. 28

    How to speed up the web service in Android?

  29. 29

    How to stop Android service when app is closed

ホットタグ

アーカイブ