function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Dallas KuhnDallas Kuhn 

java.io.IOException: No authentication challenges found

I am using the latest SalesforceMobileSDK (3.0) to build native Android apps. I use single sign-on and get a new restClient every time my main activity has resumed. 
@Override
public void onResume(RestClient client)
{
	restClient = client;
}
When I try use the restClient a day after the initial login (and after the initial authToken expired) 
private void sendRequest(String soql) throws UnsupportedEncodingException
{
	RestRequest restRequest = RestRequest.getRequestForQuery(getString(R.string.api_version), soql);

	restClient.sendAsync(restRequest, new RestClient.AsyncRequestCallback()
	{
		@Override
		public void onSuccess(RestRequest request, RestResponse result)
		{
			//process results here...
		}

		@Override
		public void onError(Exception exception)
		{
			Toast.makeText(MainActivity.this, MainActivity.this.getString(SalesforceSDKManager.getInstance().getSalesforceR().stringGenericError(), exception.toString()), Toast.LENGTH_LONG).show();
		}
	});
}
I get an 'java.io.IOException: No authentication challenges found'. This is all basic stuff and I never got this error with the previous SDK (2.0) using the same code above. After some searching I have discovered that this is caused by an unauthorized response from the server (Salesforce) but I have verified that I am correctly sending the new auth token with the request that i received back from Salesforce in my onResume method.

I have these three scopes on the connected app and in my bootConfig:
<string-array name="oauthScopes">
    <item>api</item>
    <item>web</item>
    <item>refresh_token</item>
</string-array>
I am using a Samsung Galaxy S5 running Android 4.4.2 if that info helps. Is someone able to tell me why i get this and more imortantly how to fix it?
akhilesh_sfdcakhilesh_sfdc
Are you getting the same error with the sample apps that are provided with SDK? Try creating a new native app with "forcedroid create" and run that app without any code changes. Check if you see the same session refresh issue when you re-run the app after a day.

A similar issue has been reported by another developer in our SDK community and it will be great if you can help me reproduce the issue: https://plus.google.com/u/0/104482801595232431809/posts/1Lb6oCNbUTu
Dallas KuhnDallas Kuhn
Yeah, my app is actually based off the forcedroid template.
akhilesh_sfdcakhilesh_sfdc
Dallas, can you provide us the logs when the session refresh fails? I am still trying to reproduce this issue and any clue will be helpful. I am assuming that you are running into this issue consistently.
Dallas KuhnDallas Kuhn
Hi, so last Friday I did a fresh create and install of a new sample app via forcedroid as you asked. This morning (Monday) when I got to work I opened the sample app on the device and tried to request contacts and I got the same error. This should not be difficult for you to reproduce - it happens every time. I didnt even open the project to make any changes, I just installed the app after creation via ant on the command line.

To create new sample project:
DallasKuhn:~ dallaskuhn$ forcedroid create
Enter your application type (native, hybrid_remote, or hybrid_local): native
Enter your application name: testauth
Enter the target directory of your app: davanti/android
Enter the target Android API version number for your application (at least 19 (KitKat)): 19
Enter the package name for your app (com.mycompany.my_app): com.testauth
Do you want to use SmartStore or SmartSync in your app? [yes/NO] ('No' by default) no
To build the project:
DallasKuhn:~ dallaskuhn$ cd davanti/android/testauth
DallasKuhn:testauth dallaskuhn$ ant clean debug
To install on the device:
DallasKuhn:testauth dallaskuhn$ ant installd
The full toast error is as follows:
An error has occurred com.android.volley.NoConnectionError:java.io.IOException: No authentication challenges found 
Please try again
Dallas KuhnDallas Kuhn
Hi akhilesh_sfdc, have you made any progress with this bug? 
akhilesh_sfdcakhilesh_sfdc
Dallas, we have just fixed couple issues around this for the hybrid side of our android apps. Here's the latest commit: https://github.com/forcedotcom/SalesforceMobileSDK-Android/commit/ebd6d8f647c9bbe97b73d842fda983913cc31c47

I have not been successful in reproducing this issue on the emulators and I still trying with a Samsung galaxy device. Have you also tried with the emulator? Does this issue happen for you at both places (device and emulator)?
Laszlo UrszulyLaszlo Urszuly

I'm sorry to hook in to a discussion like this, being a complete stranger to all of you, but I have experienced this very behaviour (and Java Exception stack) in other areas. In my case (completely isolated from SalesForce) it turned out that the server side API was sending a 401 without passing along a proper WWW-Authenticate header. Since the header is required by standard (http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html), the Android HttpURLConnection was forced to throw an IOException with the message "No authentication challenges found" because of the faulty header.

I could mainly see this on JellyBean Android platforms. This link (https://android.googlesource.com/platform/libcore/+/android-4.1.2_r1/luni/src/main/java/libcore/net/http/HttpURLConnectionImpl.java) would point to the Android 4.1 implementation of said http connection.

I could fix my issue by correcting the server side API to also include a standards compliant header, but I still see the issue on Samsung Galaxy S3 devices (still only on JellyBean Androids 4.1 - 4.3). Now I don't know if the issue is due to an alternative Samsung Android implementation or due to a majority of my userbase being located in a geographic area where headers are removed by governments or Internet providers. I am yet to find a good solution for those devices, meanwhile having a ugly "if (samsung)" test in my code.

I hope I could bring something useful to the discussion.

akhilesh_sfdcakhilesh_sfdc
Thanks Laszlo for your suggestions. I actually verified that we do have the right headers. Also seems like this is happening for some of our kitkat users. 

Dallas, is this still an issues?
Dallas KuhnDallas Kuhn
Hi akhilesh_sfdc, 
I have been working on another app (non SF) so i am not  entirely sure if it's still happening. I will run the app on a device and emulator and I will verify tomorrow as to whether this is still happening or not. 
 
Dallas KuhnDallas Kuhn
akhilesh_sfdc, sorry for the delay. Yes I can verify this is still happening on a device so it is still an issue. I have not tested in an emulator, but clients run these apps on a device so that is where the problem lies and an emulator is irrelevant at the end of the day.
Steven CortinovisSteven Cortinovis
Hi everyone and thanks for your collaboration. I'm stuck in the same problem. Even the workaround of loggin out from the app, empy cache and re-login does not always work.
Dallas KuhnDallas Kuhn
I have uncovered an interesting discovery for those who are interested....

So I updated to the latest version of the MobileSDK (3.1.1) and created a new test app using the same steps listed above. I then installed the test app on a LG Nexus 5 (Android 5.0.2), Sony Z2 (Android 4.4.4), Samsung Note 10.1" (Android 4.4.2), HTC M8 (Android 4.4.4), Samsung Ace 3 (Android 4.2.2). I logged in with my SF credentials on each device and then closed the app. Upon returning to the app 24 hours later on each device and requesting data from SF, all devices returned the data except for the Samsung Ace 3, which gave the error 'java.io.IOException: No authentication challenges found'.

This may or may not be of help to someone else, I thought it interesting that it's device-specific. Previously it was on a Samsung Galaxy S5, now on a Samsung Ace 3 - the other devices were fine.
Steven CortinovisSteven Cortinovis
Thanks Dallas, actually I encounter the problem on a Samsung Note 10.1
Steven CortinovisSteven Cortinovis
I also get the error on this devices:
Lenovo  B8000-H
Versione android: 4.2.2
 
Galay Tab 10.1 2014
Codice Modello SM-T335
Versione android: 4.4.2

Galaxy Tab 4
Codice modello:SM-P605
Versione Android: 4.3

The ​Salesforce SDK version is:
android:versionCode="40"
android:versionName="3.1.0"
 
And finally, this is the error log:
03-26 14:55:16.125: W/errore(28271): com.android.volley.NoConnectionError: java.io.IOException: No authentication challenges found
03-26 14:55:16.125: W/errore(28271): 	at com.android.volley.toolbox.BasicNetwork.performRequest(BasicNetwork.java:134)
03-26 14:55:16.125: W/errore(28271): 	at com.android.volley.NetworkDispatcher.run(NetworkDispatcher.java:110)
03-26 14:55:16.125: W/errore(28271): Caused by: java.io.IOException: No authentication challenges found
03-26 14:55:16.125: W/errore(28271): 	at libcore.net.http.HttpURLConnectionImpl.getAuthorizationCredentials(HttpURLConnectionImpl.java:438)
03-26 14:55:16.125: W/errore(28271): 	at libcore.net.http.HttpURLConnectionImpl.processAuthHeader(HttpURLConnectionImpl.java:418)
03-26 14:55:16.125: W/errore(28271): 	at libcore.net.http.HttpURLConnectionImpl.processResponseHeaders(HttpURLConnectionImpl.java:367)
03-26 14:55:16.125: W/errore(28271): 	at libcore.net.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:301)
03-26 14:55:16.125: W/errore(28271): 	at libcore.net.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:497)
03-26 14:55:16.125: W/errore(28271): 	at libcore.net.http.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:134)
03-26 14:55:16.125: W/errore(28271): 	at com.salesforce.androidsdk.auth.HttpAccess.execute(HttpAccess.java:303)
03-26 14:55:16.125: W/errore(28271): 	at com.salesforce.androidsdk.auth.HttpAccess.doGet(HttpAccess.java:238)
03-26 14:55:16.125: W/errore(28271): 	at com.salesforce.androidsdk.rest.RestClient$SalesforceHttpStack.performRequest(RestClient.java:497)
03-26 14:55:16.125: W/errore(28271): 	at com.salesforce.androidsdk.rest.RestClient$SalesforceHttpStack.performRequest(RestClient.java:425)
03-26 14:55:16.125: W/errore(28271): 	at com.android.volley.toolbox.BasicNetwork.performRequest(BasicNetwork.java:93)

Can you provide us some workaround?
Kartik MarujollaKartik Marujolla

We have also seen the same issue in tha ALCATEL ONE TOUCH Fierce ,Strange thing is even after we re login the issue continues to exist for couple of hours and then its works as if its normal..

Current SDK version we are using is 3.1.1 and its the same with the sample apps on this phone.
we can reproduce this issue by revoking the session and restarting  the phone .or restart the phone revoke the session and open the app

Dallas KuhnDallas Kuhn
Hi there,

Seven months later I am still receiving reports from my users complaining about this issue. Can anyone from SF provide a solution oto this or perhaps know the root cause?

I am using the latest SF MobileSDK (3.2.1) and minSdkVersion 18 for Android.

From what I can tell SF should be returning a 'WWW-Authenticate' header but is not. Can we make that happen somewhow?
Kartik MarujollaKartik Marujolla
Hello Dallas Kuhn,
I am using salesforce SDK version 3.3.0(44) and minSdkVersion 14 for Android.Its still the same.
 
Dallas KuhnDallas Kuhn
Ah, I see there is a new version released a week ago - I will update to that and see if the issue is resolved. Thanks!
Kartik MarujollaKartik Marujolla
Issue is still not resolved ,on 3.3.0(44) i am facing the same problem on  ALCATEL ONE TOUCH Fierce
akhilesh_sfdcakhilesh_sfdc
Dallas, we did check on the response headers and found that salesforce is returning the 'WWW-Authenticate' header properly? Are you sure your app is not receiving this header from salesforce? Also are you guys able to reproduce this on android emulator?

Since this error has been localized to certain android devices, our current assumption is that it's something unique about those android builds. It will be really helpful if you can reproduce this issue on emulator and can share the raw http response from salesforce.
Andrew CawoodAndrew Cawood
I've been hitting the same "No authentication challenges found" error on an Acer Z160 running Android 4.2.2, but with the SalesForce1 app (not a custom app).
This happens when I try to refresh my tabs-list (by pulling down and releasing). Update to latest SF1 version (7.3.1 Build 56) did not help.
 
FemiFemi
Please is any one still looking at this?
This is still happening using Salesforce SDK 3.3.1 (the current latest). On Android 4.2.2 (Same as above)

Cheers