How to debug Cloudendpoints with GiTkit in the Android Emulator

227 views Asked by At

I have set up some Cloud Endpoints in Android Studio and implemented an Authenticator (com.google.api.server.spi.config.Authenticator) which gets invoked with every call to a cloud endpoint.

Now I want to use my authenticator to check the login from Android with GiTkit (Google Identity Toolkit). When I debug my endpoints I can check them with a local URL like http://localhost:8080/_ah/api/userApi/v1/login/ . In the Android emulator the local loopback address is 10.0.2.2 so the URL would be http://10.0.2.2:8080/_ah/api/userApi/v1/login/ (which is working in the Android Browser).

But I can't change the the Authorized redirect URI form localhost to this URL in the Google developer console (Client ID for web application). (Invalid Redirect: http://10.0.2.2:8080/_ah/api/userApi/v1/login/ must end with a public top-level domain (such as .com or .org))

How can I debug my Cloud Endpoint together with GiTkit in the Android Emulator (or on the Phone)?

1

There are 1 answers

0
Hollerweger On BEST ANSWER

I got an answer from Derek Salama that it is not possible on the google group: https://groups.google.com/forum/#!topic/google-identity-toolkit/RNyW8xN7q7E

Hi Martin,

You're correct that the redirect URI for the Client ID cannot be an IP address, and thus http://10.0.2.2:8080/ doesn't work while http://localhost:8080 does.

I don't know of any magic that would let you access the localhost from an Android emulator without using the IP address. When developing with Identity Toolkit and Cloud Endpoints, I first test the Authenticator implementation with the Endpoints API explorer (after using curl to get a valid ID token). Once I'm confident the authenticator is working, I deploy to appengine and test the Android app against a live instance.

I have now set up a localhost sample site according to https://developers.google.com/identity/toolkit/web/setup-frontend for easy debugging.