Bluemix sample app fails with “Failed to authentic

2019-07-14 08:30发布

问题:

I'm trying to build and run this Bluemix sample app:

BMS samples: helloTodoAdvanced

I'm following the instructions in the project's README.md verbatim. Specifically:

  1. Clean checkout of the bms-samples-hellotodo-advanced project from Github.

  2. Created a new Bluemix "MobileFirst Starter" boilerplace app.

  3. Verified the basic functionality from the Bluemix console and the Web UI.

  4. Created a new Facebook app ID, using the package and class in the sample app.

  5. Configured BlueMix Mobile Client Access (MCA) to use my Facebook App ID.

  6. Updated the NodeJS server.js app per the project instructions.

  7. Modified the Android app source with the Facebook App ID, Bluemix route and Bluemix app guid.

  8. I'm running on a Genymotion emulator: a Samsung Galaxy Sr/Android API 18

  9. Here is the Android Studio logcat from an attempted run:

04-04 17:19:58.859 1276-1298/com.ibm.hellotodoadvanced E/MainActivity: Failed to authenticate against MCA: Response: {"error":"unauthorized_client","error_description":"Unknown client"}
04-04 17:19:58.859 1276-1298/com.ibm.hellotodoadvanced E/MainActivity: Failed to authenticate against MCA, unknown reason
04-04 17:19:58.863 1276-1291/com.ibm.hellotodoadvanced E/mfpsdk.AuthorizationProcessManager: AuthorizationProcessManager.handleAuthorizationFailure in AuthorizationProcessManager.java:426 :: authorization process failed

<= The program loads and runs ... but authentication fails with this error!

Q: Any suggestions as to how I can debug the "Failed to authenticate against MCA" errors?

Q: Are you supposed to log on to Facebook directly from Android?

My understanding is "No" - Bluemix authenticates the app directly with Facebook; the Android user is irrelevant.

Q: Are there any other "gotcha's" needed to get MCA authentication working with Bluemix for Android?

回答1:

I think you need to uninstall your app from the device and then reinstall it , it usually the issue in a case of "unknown client".
Q1 : I don't think there is any special way to debug the authentication flow (just the regular android debugger )
Q2) yes the flow is: the user login to facebook the token then sent to the MCA server which validates it and grants you MCA token which will let you get to your protected resource.
Q3) You need to do all the instructions of adding facebook to an android app (if you see the facebook popup so I think you did this flow ). you can follow this link for more info