google-api-java-client

Google Directory API returns Not Authorized when call users().list().execute()

江枫思渺然 提交于 2019-11-27 22:34:37
问题 I need to read the list of users (and groups) from my google domain. So I went to my Google APIs Console and enabled Admin SDK and created a Service Account to call Google APIs. I use the following google libraries google-api-services-admin-directory_v1-rev11-1.16.0-rc.jar google-api-client-1.16.0-rc.jar My code is /* * Global instance of the JSON factory. */ final JsonFactory JSON_FACTORY = JacksonFactory.getDefaultInstance(); /* Global instance of the HTTP transport. */ HttpTransport

OAuth Google API for Java unable to impersonate user

心已入冬 提交于 2019-11-27 15:16:21
问题 I would like to impersonate a user and add files to the users Google Drive on their behalf from a server process. I've setup a service account and can successfully access the Drive as the service account adding and listing files, etc. using the following code: /** Global instance of the HTTP transport. */ private static final HttpTransport HTTP_TRANSPORT = new NetHttpTransport(); /** Global instance of the JSON factory. */ private static final JsonFactory JSON_FACTORY = new JacksonFactory();

Gmail atom feed with 2-legged OAuth receive 401 error

落爺英雄遲暮 提交于 2019-11-27 12:08:14
问题 We are experiencing the issue of Gmail atom feed with 2-legged OAuth, an error message is "401 unauthorized". The error message is like below. <HTML> <HEAD> <TITLE>Unauthorized</TITLE> </HEAD> <BODY BGCOLOR="#FFFFFF" TEXT="#000000"> <H1>Unauthorized</H1> <H2>Error 401</H2> </BODY> </HTML> Until last week, we have no problem using Gmail atom feed. From this week, we are experiencing the issue even though we have a no change regarding Gmail atom feed and oauth. Now, this problem do not occurs

Using Google Cloud Storage JSON api in android

天涯浪子 提交于 2019-11-27 11:00:59
问题 I want to upload image on Google Cloud Storage from my android app. For that I searched and found that GCS JSON Api provides this feature. I did a lot of research for Android sample which demonstrates its use. On the developer site they have provided code example that only support java. I don't know how to use that API in Android. I referred this and this links but couldn't get much idea. Please guide me on how i can use this api with android app. 回答1: Ok guys so I solved it and got my images

Uploading image from Android to GCS

荒凉一梦 提交于 2019-11-27 06:55:19
I am trying to upload an image from Android directly to Google cloud storage. But the API does not seem to work. They have some Java samples which are tied to the App engine. I don't see any sample which is proven to work on Android. On Android, I tried using the json api to upload an image. I am able to upload an image object but it seems to be corrupt. Moreover generating the authentication token seems to be tricky too. I am struck with this right now. Did anyone on this earth ever tried uploading an image/video from Android using Java client or Json API and succeeded? Can someone point me

Getting a 403 - Forbidden for Google Service Account

一世执手 提交于 2019-11-27 05:22:26
I am trying to get an access token for Google Service Account. Following is my code - String SERVICE_ACCOUNT_EMAIL = "edited@developer.gserviceaccount.com"; List scope = new ArrayList(); scope.add("https://www.googleapis.com/auth/admin.directory.user"); String keyFile = "C:\\edited-privatekey.p12"; HttpTransport HTTP_TRANSPORT = new NetHttpTransport(); JsonFactory JSON_FACTORY = new JacksonFactory(); GoogleCredential credential = new GoogleCredential.Builder() .setTransport(HTTP_TRANSPORT) .setJsonFactory(JSON_FACTORY) .setServiceAccountId(SERVICE_ACCOUNT_EMAIL) .setServiceAccountScopes(scope)

Google Drive API doesn't play well with ProGuard (NPE)

二次信任 提交于 2019-11-27 03:57:51
Currently, I'm having experience that, a piece of code, which makes use of Google Drive API is running fine without introducing ProGuard. However, after introducing ProGuard, I'm getting the following run-time error. at java.lang.Thread.run(Thread.java:856) Caused by: java.lang.NullPointerException at com.google.api.client.util.Types.getActualParameterAtPosition(Types.java:329) at com.google.api.client.util.Types.getIterableParameter(Types.java:309) at com.google.api.client.json.JsonParser.parseValue(JsonParser.java:546) at com.google.api.client.json.JsonParser.parse(JsonParser.java:350) at

Error: 'The project id used to call the Google Play Developer API has not been linked in the Google Play Developer Console.'

吃可爱长大的小学妹 提交于 2019-11-27 03:30:20
I am getting the following error while accessing Google Play Developer API using a service account: The project id used to call the Google Play Developer API has not been linked in the Google Play Developer Console. The service account email and .p12 file were generated using the service account option in APIs&Auth -> Credentials . The Application in the Google Play Developer API was linked to the project using the project id as mentioned in google's docs. However, I am still getting this error when I try to use the Publishing API. I am looking for a solution to this error and a step by step

Access to Google API - GoogleAccountCredential.usingOAuth2 vs GoogleAuthUtil.getToken()

五迷三道 提交于 2019-11-27 03:18:00
Lately, I have been working a lot with Google APIs on Android especially Analytics, AdSense and Tasks API. I have seen some samples provided by Google where they use this statement to obtain a GoogleAccountCredential object https://code.google.com/p/google-api-java-client/source/browse/tasks-android-sample/src/main/java/com/google/api/services/samples/tasks/android/TasksSample.java?repo=samples credential = GoogleAccountCredential.usingOAuth2(this, Collections.singleton(TasksScopes.TASKS)); However, If I go through the documentation such as: http://developer.android.com/google/auth/http-auth

OAuth2 and Google API: Access token expiration time?

瘦欲@ 提交于 2019-11-27 02:50:37
We have a standalone Java application (see 'Installed application': https://developers.google.com/accounts/docs/OAuth2 ) which runs periodically and uses google API (updates some informations from customer databases/ldap/...). To access Google APIs we store username and password in configuration file, which is a security risk and customer does not like that. So we would like to use OAuth2 long-living access token instead. what`s default expiration time for Google OAuth2 access tokens ? As we will have only access token in application, app itself cannot refresh it when access token expires...