Skip to content

This repository is a HelloWorld Android sample application that connects to a HelloWorld Google Cloud Endpoints backend sample.

License

Notifications You must be signed in to change notification settings

PaulRashidi/appengine-endpoints-helloendpoints-android

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

appengine-endpoints-helloendpoints-android

This application is a HelloWorld Android sample application that connects to a HelloWorld Google Cloud Endpoints backend sample.

Products

Language

APIs

Setup Instructions

  1. Deploy a Google Cloud Endpoints backend sample that this client app will use as an API server. Proceed with optional authentication steps during setup.

  2. Install Android Studio.

  3. Download code git clone https://github.com/GoogleCloudPlatform/appengine-endpoints-helloendpoints-android.git

  4. Import the project:

    1. Open AndroidStudio and choose "Import Project."
    2. Select the build.gradle file in the HelloEndpointsProject directory and use default values for the rest of the import screens.
    3. NOTE: If you recieve an import error indicating that "play-services", a required dependency, could not be found that is OK. It will be resolved by the following step.
  5. Check dependencies (even if the project compiles) using the Android SDK Manager. Ensure the following packages are installed and up-to-date:

    1. Android Support Repository
    2. Android Support Library
    3. Google Play Services
    4. Google Repository
  6. Close and reopen your project. Clean dependencies using the Build menu by choosing "Rebuild Project."

  7. Update the file HelloEndpointsProject/HelloEndpoints/src/main/java/com/google/api/services/helloworld/Helloworld.java with the location of your deployed API. DEFAULT_ROOT_URL should include your App Engine app ID.

  8. Deploy the Android App

    1. Deploy your app via normal Android deployment procedures.

NOTE: At this point you can deploy the app and all anonymous API calls will work. The authenticated API call will not work; continue on to configure the Android application to securely communicate with your backend sample.

  1. Register an Android Application to access your Google Cloud Endpoints backend project.

    1. Navigate to the Google Cloud Console. Select the Google Cloud Endpoints Backend project that was deployed as in Step 1.
    2. Navigate to the "APIs & Auth," item of the left menu bar.
    3. Choose the "Credentials" submenu item.
    4. Click "Create new Client ID" and select "Installed Application" and "Android."
    5. Use com.google.devrel.samples.helloendpoints as the package name.
    6. Retrieve your debugging keystore fingerprint from ADB. On a Mac this command would typically look like this with an empty password: keytool -list -v -keystore ~/.android/debug.keystore
    7. Click "Create Client ID."
  2. Associate your Google Cloud Endpoints backend project to the Android application.

    1. Update the file HelloEngpoints/src/main/java/com/google/devrel/samples/helloendpoints/AppConstants.java. WEB_CLIENT_ID field should be updated with the web application client ID that is defined in the "APIs & Auth" -> "Credentials" screen of your Google Cloud Endpoints backend project. You will be using the Client ID specified for "Compute Engine and App Engine."
    2. You will similarly need to update your Google Cloud Endpoints backend sample with the Android application client ID as well. Do not forget to recompile your backend app (such as with mvn clean install for the Java one).
  3. Deploy the Android App

    1. Deploy your app via normal Android deployment procedures.
    2. You will need to use a version 17 or later "Google APIs" enabled AVD definition if you are using an emulator instead of a physical device. Physical devices need only Google Play (Services) installed to work.
  4. A quick note about the Client IDs used above for Authentication. -Client IDs identify applications (client or backend) to Google. The authenticated APIs in this sample utilize OAuth2 authentication. OAuth2 tokens are issued to specific Client IDs and therefore the Client IDs can be used for restricting access to your APIs. -When you create a Google Cloud Console Project a default Client ID is created and named for use by the project. When you upload an App Engine project it uses that Client ID. This becomes the WEB_CLIENT_ID referenced in the Android/iOS/Backend samples. -When you register the iOS or Android Applications in the Google Cloud Console you are creating another Client ID. This Client ID is the one requesting an OAuth2 token from Google for authentication purposes. When the API is used in an authenticated manner an OAuth2 access token is sent and opened by Google Cloud Endpoints. The Client ID is extracted from the token and compared to the backend's declared acceptable Client ID list.

About

This repository is a HelloWorld Android sample application that connects to a HelloWorld Google Cloud Endpoints backend sample.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%