How to add client id to Google Drive Client API for Java

google drive api java
upload file to google drive using java
google drive api without oauth
google drive api service account
google drive api v3
google drive api authentication
how to create api for google drive
google drive client id

I'm just getting started with using the Google Drive REST API in an Android app. (I can't use the Google Drive API for Android because the app needs to share files, and perhaps a few other things, that GDAA doesn't support.) I'm stuck on a couple of points.

The first has to do with OAuth2.0 credentials. I went through the Android quick start example and it works fine. I set up a project on my Google developer console and generated an OAuth2.0 client ID and secret and also downloaded the JSON credentials file. However, the quick start example doesn't show how to plug any of this into the app. The only thing I found in the docs that seems relevant is GoogleClientSecrets, but I don't see anything about how to use that in an Android app. (The Java quick start example uses this, but it's not integrated with Android's account manager and doesn't seem right for an Android app.) When I run the Android version of the quick start app, no activity shows up on my developer console, which suggests to me that the app is running in some sort of anonymous mode. As I understand it, that would limit the app to a very low daily quota of transactions.

Second, I noticed that the GDAA and the REST API for JavaScript both have nice file picker APIs. I couldn't find anything similar in the Java/Android API.

So here are my specific questions:

  • How do I use my app's OAuth2.0 credentials from the developer console in a REST API for Android Java app? I feel like I'm just missing something obvious.
  • Is there a file picker API for the Google Rest API for Android?

After stepping through the library as I executed the Quickstart example (a painful process, as there is no source code), I discovered the answer. It turns out that you need to specify the client ID in the manifest. Specifically, you needs the following under the <application> tag:

    android:value="app ID from your API console"/>

Once this entry is in the manifest, then when the app uses the Google Drive REST API to interact with Google's servers, the transaction is correctly logged as traffic in your app's console. Without this entry, the app seemed to work in my testing, but no traffic was logged. I seem to recall (from an old Google I/O video) that such "anonymous" apps still work, but have a very low usage quota (something like 10 or 100 queries/day).

For those who are curious, I found this key in the class, found in the play-services-basement-10.2.0 library.

What is my client ID?, , also referred to as a UCI , is on all documents you get from us. It is an eight or ten-digit number that looks like this: 0000-0000 or 00-0000-0000. This tutorial shows how to enable the Google Drive API for a specific Google account, and get the access credentials to be used from Iperius to make cloud backups. In fact, to make an online backup to Google Drive you first need to enable some specific options, then you have to create an account into […]

How do I use my app's OAuth2.0 credentials from the developer console in a REST API

The pages around give you all that you need to know. In particular, note the Java Quickstart you were using is for generic Java. The way Google Play Services on Android manage credentials and accounts is very Android-specific.

Is there a file picker API for the Google Rest API for Android?

Not that I know of, but depending on your use case, you might be able to use the GDAA picker. Ultimately, both GDAA and the Java REST API are layers above your Drive storage.

An Introduction to OAuth 2, How do I find my Google client ID and client secret? If this is your first time creating a client ID in this project, use the sub-steps to go to the OAuth consent page; otherwise, skip to the next step. Click OAuth consent screen. Enter a name in the Application name field. Fill out the rest of the fields as needed. Click Save. In the Create credentials drop-down list, select OAuth client ID.

Save the client_id.json file downloaded from the Google API console into into your app's src/main/res directory.

I was stuck exactly the same, but after I built my app with the file included the Google API started working.

How to add client id to Google Drive Client API for Java, is a publicly exposed string that is used by the service API to identify the application, and is also used to build authorization URLs that are presented to users. To use client ID and client secret to access Google Drive, you need to first generate the client ID and client secret by completing the following steps using Google Chrome. Before you begin A Google account has already been signed up for using Google Drive.

Authenticate your users | Google Drive API, After stepping through the library as I executed the Quickstart example (a painful process, as there is no source code), I discovered the answer. To work with Google APIs, you will need Google API Console project and Client Id. Which you can use to call different Google APIs. I wanted to integrate Google Sign-In into my website. The following blog post explains how to create Google API Console project, client ID and client Secret.

Java Quickstart | Google Drive API, Every request your application sends to the Drive API must include an information you'll need later, such as a client ID and a client secret. In some cases, your application may need to use the Google APIs Client Library for Java to access features or authorization scopes that are not available in the Google Drive Android API. Using the Google Drive web services through the Java client library and the Android Development Kit, you can integrate a mobile app with Google Drive on Android.

Google Drive API and Java get a client id and a client secret for my , Click this button to create a new Cloud Platform project and automatically enable the Drive API: Enable the Drive API import​javanet. .build(); // Print the names and IDs for up to 10 files. Google APIs Client for Java documentation; Drive API Javadoc documentation; Drive REST API reference documentation; Troubleshooting. This section describes some common issues that you may encounter while attempting to run this quickstart and suggests possible solutions. This app isn't verified.

  • The Java Quickstart I was using was not for generic Java; it was specifically the REST Quickstart for Android. There's a separate generic Java Quickstart here. The pages you pointed me to still don't answer my question. What do I do with the client ID generated through my developer console? There's no place in any of the docs (that I can find) on where that info goes in my app. Regarding mixing REST with the GDAA picker: is there a risk that the app will prompt twice for permission to access the user's drive?
  • Did you read in conjunction with Steps 1 and 2 from the Android Quickstart link you posted? The point is that Client auth for Android apps that use Play Services to manage the auth dialogue don't use client-IDs in the same way that (say) a generic Java or php app would.
  • Yes, I read that. It explains how to register my signing certificate in the developer console, but it doesn't say how to use the API key that the console generates. That's where I'm stuck. The plain Java version of the REST Quickstart shows how to read in a JSON file to get this information, but the Android REST Quickstart doesn't show anything like this. I guess I'm looking for something that would go into the manifest, like what one would do with the Google Places API. Are you saying that this just isn't needed for Drive?
  • For Android credentials, the client ID is bound to the package signature in the API Console, therefore there is no need for it to be installed within the app or manifest. Simply by virtue of the calls coming from, Google knows the client ID. This is all assuming that you are using Play Services for the Auth flow. If you're rolling your own (definitely not recommended), then you'll be using it just as you would in a generic Java app.
  • When the app is credentialed solely based on the package signature as you describe, app traffic does not seem to appear in my developer's API console. When the client ID is embedded in the manifest (as I describe in my answer) then the traffic is logged. If things are as you describe, what explains this difference?