google-api-java-client

Create users using Service Account with Google Admin SDK?

一笑奈何 提交于 2019-12-04 20:07:13
The documentation is a little unclear on this. Can I actually do this? The only examples I've seen so far are from the Google documentation that show it using the GoogleAuthorizationCodeFlow class to gain authorization. I've seen a few examples of using the Service Account to update and retrieve a list of users, but nothing for creating. Is this possible? If so, does anyone know of any examples floating around? I can't seem to find anything that addresses it. omerio You can follow the steps outlined in the following API docs page to create the service account and perform a domain wide

GmailApiQuickstart -

喜你入骨 提交于 2019-12-04 15:55:35
问题 I am embarrassed that I'm simply failing with an example piece of code, but I'll blame it on the fact that it is late... I have taken a copy and paste of: https://developers.google.com/gmail/api/quickstart/quickstart-java and downloaded the client libraries: https://code.google.com/p/google-api-java-client/ and https://developers.google.com/api-client-library/java/apis/gmail/v1 When I run the sample, I get the following exception: Exception in thread "main" java.lang.IllegalArgumentException

Google Drive Upload returns 50x server errors intermittently

删除回忆录丶 提交于 2019-12-04 15:41:15
I'm using the java google drive API to upload some files into various Google Drive folders. The user whose credentials I'm using has access to all the folders. I am uploading around 100 PDFs and 100 CSV files from two different servers running CentOS. These are typically updates though I do occasionally insert the files. These files are between 35k and 700 bytes in size, so not large. About a week ago, I started getting exceptions when uploading the CSV files (but not the PDF files). The exceptions look like this: com.google.api.client.googleapis.json.GoogleJsonResponseException: 500 Internal

Setting uploadType in Google Drive Java API

自作多情 提交于 2019-12-04 11:31:10
I'm having the same problem as this and this but in the Java domain. This question also covers what I want but since no answers have been forthcoming I thought I'd ask it here, with a little more detail. I'm most of the way through writing a Java application to back up files to Google Drive. As others have found, 'internal server error 500' failures are a pretty common problem with uploads, but for small files, implementing the recommended exponential back-off and retry works okay. For large files, however, (anything over a few MB) the failure rate is unacceptably high. In some cases I'm

java google custom search api

青春壹個敷衍的年華 提交于 2019-12-04 09:35:13
问题 I'm trying to use the java client for the Google custom search api but couldn't find any sample tutorials on the web. Can someone provide a simple example for me to get started? Thank you! 回答1: I want to make a correction here. customsearch.setKey("YOUR_API_KEY_GOES_HERE"); does not work for client lib 1.6 but following does work Customsearch customsearch = new Customsearch(new NetHttpTransport(), new JacksonFactory()); try { com.google.api.services.customsearch.Customsearch.Cse.List list =

Rare NullPointerException in GoogleApiClient using Firebase

情到浓时终转凉″ 提交于 2019-12-04 09:13:58
问题 I am using GoogleApiClient to login users using their Google account. Basically, I am using Firebase Auth with Google sign in. But I am getting this crash on some devices every single day . When I test on some of my own devices (OnePlus 3, Nexus 5X, Moto G, etc) I never see this crash. Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.String.toLowerCase(java.util.Locale)' on a null object reference at com.google.android.gms.internal

How to use Google QPX API with Java for flight search?

别来无恙 提交于 2019-12-04 06:34:11
I am trying to build a simple Java code that obtains flight options using Google QPX API, for the flight from New York to London. I signed up with Google and got API_key. I read the documentation, but unfortunately, I couldn't find any example that show me how to do it. Here what I tried so far: import com.google.api.services.qpxExpress.model.*; import java.util.*; public class Main { public static void main(String[] args) { // Passengers PassengerCounts passengers = new PassengerCounts(); passengers.setAdultCount(2); // Slice List<SliceInput> slices = new ArrayList<SliceInput>(); SliceInput

How to correctly obtain user's Calendar events using service account?

时间秒杀一切 提交于 2019-12-04 05:15:27
I'm trying to retrive Calendar events for a user in a domain. I have service account access, but i get 404 error when I try to get specific user events. Heres connection code: NetHttpTransport httpTransport = GoogleNetHttpTransport.newTrustedTransport(); GoogleCredential credential = new GoogleCredential.Builder() .setTransport(httpTransport) .setJsonFactory(JSON_FACTORY) .setServiceAccountId(googleApiServiceAccountId) .setServiceAccountScopes(Collections.singleton(CalendarScopes.CALENDAR_READONLY)) .setServiceAccountPrivateKey(SecurityUtils.loadPrivateKeyFromKeyStore( SecurityUtils

Google Webmasters API for Java returns empty site list

落花浮王杯 提交于 2019-12-04 03:53:47
I have written a simple site list query code which uses Oauth with service account based on Google's documentation . The authentication key file (.p12) being used is valid as well as the account. The problem is that sites list method returns an empty list. service.sites().list().execute(); Also if I explicitly try to get sitemaps of a validated site, by calling service.sitemaps().list("my.sample.site.com").execute(); I got a 403 Forbidden - "User does not have sufficient permission for site 'sample.site.com'. See also: https://support.google.com/webmasters/answer/2451999 ." error from the API.

Stored Credential from google api to be reused java

北慕城南 提交于 2019-12-04 00:36:19
问题 I have successfully authorized my desktop application. It stores a file called StoredCredential . In order to not have to keep doing the copy URL into browser, accept, etc., steps every time I run the app, I want to use the credentials that I already have stored. My code so far: GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder( httpTransport, JSON_FACTORY, CLIENT_ID, CLIENT_SECRET, SCOPE) .setDataStoreFactory(dataStoreFactory) .setApprovalPrompt("auto").setAccessType