Closed drcariel closed 7 years ago
@rotembr Looks like a trailing slash issue here: imf-authserverf37159c3-862e-4f33-9310-d2d7021fd3f3. Please check ASAP.
The new initialize method should be invoke as follows:
BMSClient.getInstance().initialize(this, BMSClient.REGION_US_SOUTH);
And use the new create of the MCAAuthorizationManager with AppID:
MCAAuthorizationManager.createInstance(this.getApplicationContext(), AppID);
Note that the new initialize function can receive multiple String arguments, also known as varargs feature, you should pass only one String represent the region (BMSClient.REGION_US_SOUTH), this is a preparation if we ever support retries with multiple regions.
And don't forget to register the MCAAuthorizationManager with BMSClient, your code should look something like this: If you use Custom authentication -
BMSClient.getInstance().initialize(getApplicationContext(), BMSClient.REGION_US_SOUTH);
MCAAuthorizationManager mcaAuthorizationManager = MCAAuthorizationManager.createInstance(this.getApplicationContext(), AppID);
mcaAuthorizationManager.registerAuthenticationListener("realm_name", new CustomChallengeHandler());
BMSClient.getInstance().setAuthorizationManager(mcaAuthorizationManager);
If you use Google authentication -
BMSClient.getInstance().initialize(getApplicationContext(), BMSClient.REGION_US_SOUTH);
BMSClient.getInstance().setAuthorizationManager(MCAAuthorizationManager.createInstance(this, AppID));
GoogleAuthenticationManager.getInstance().register(this);
If you use Facebook authentication -
BMSClient.getInstance().initialize(getApplicationContext(), BMSClient.REGION_US_SOUTH);
BMSClient.getInstance().setAuthorizationManager(MCAAuthorizationManager.createInstance(this, AppID));
FacebookAuthenticationManager.getInstance().register(this);
Also note that since we don't pass the 'route' parameter anymore in the new init method, if you have a request with relative path, you need to change it to include the full URI. i.e:
Request r = new Request("/protected", Request.GET); //this is not supported with the new init
change to:
Request r = new Request("<URL>/protected", Request.GET);
It seems this is solved; if it is not, please reopen and add more details.
Yes, I was missing the appID param in the auth manager create. I will make sure this is reflected in our docs and samples. Thanks @rotembr
When using the updated initialization function for Android, I can no longer successfully authenticate my Android app against MCA.
Updated API: BMSClient.getInstance().initialize(this, "AppID", BMSClient.REGION_US_SOUTH);
Exception: java.net.UnknownHostException: Unable to resolve host "imf-authserverf37159c3-862e-4f33-9310-d2d7021fd3f3": No address associated with hostname at java.net.InetAddress.lookupHostByName(InetAddress.java:470) at java.net.InetAddress.getAllByNameImpl(InetAddress.java:252) at java.net.InetAddress.getAllByName(InetAddress.java:215) at com.squareup.okhttp.Dns$1.lookup(Dns.java:39) at com.squareup.okhttp.internal.http.RouteSelector.resetNextInetSocketAddress(RouteSelector.java:175) at com.squareup.okhttp.internal.http.RouteSelector.nextProxy(RouteSelector.java:141) at com.squareup.okhttp.internal.http.RouteSelector.next(RouteSelector.java:83) at com.squareup.okhttp.internal.http.StreamAllocation.findConnection(StreamAllocation.java:174) at com.squareup.okhttp.internal.http.StreamAllocation.findHealthyConnection(StreamAllocation.java:126) at com.squareup.okhttp.internal.http.StreamAllocation.newStream(StreamAllocation.java:95) at com.squareup.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:281) at com.squareup.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:224) at com.squareup.okhttp.Call.getResponse(Call.java:286) at com.squareup.okhttp.Call$ApplicationInterceptorChain.proceed(Call.java:243) at com.squareup.okhttp.Call.getResponseWithInterceptorChain(Call.java:205) at com.squareup.okhttp.Call.access$100(Call.java:35) at com.squareup.okhttp.internal.NamedRunnable.run(NamedRunnable.java:33) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) at java.lang.Thread.run(Thread.java:818) Caused by: android.system.GaiException: android_getaddrinfo failed: EAI_NODATA (No address associated with hostname) at libcore.io.Posix.android_getaddrinfo(Native Method) at libcore.io.ForwardingOs.android_getaddrinfo(ForwardingOs.java:55) at java.net.InetAddress.lookupHostByName(InetAddress.java:451) ... 20 more Get request to Bluemix failed: Unable to access Bluemix host! Please verify internet connectivity and try again.