google-api-java-client

How to mock Google API AndroidPublisher request

末鹿安然 提交于 2020-01-04 06:11:01
问题 I've got a class that makes a request to the AndroidPublisher API to get the Purchases.Subscriptions.get resource. How does one mock out the OAuth request and call to get the subscription resource using the classes from the package com.google.api.client.testing? Here is the code to get the subscription: HttpTransport httpTransport = new NetHttpTransport.Builder().build(); JsonFactory jsonFactory = JacksonFactory.getDefaultInstance(); GoogleCredential credential = new GoogleCredential.Builder(

Creating a Google HTTP Transport Object for Android HTTP Request

余生长醉 提交于 2020-01-02 08:56:32
问题 I'm creating an Android app and trying to use Google Places API through Google APIs Client. I've been following this example: http://ddewaele.blogspot.com/2011/05/introducing-google-places-api.html I'm having problems creating a HTTP Transport Object to use in creating the HTTP Request Factory. Everything compiles fine in eclipse, but when I debug while running on my phone, I get a classnotfound on the first line here: HttpTransport transport = new ApacheHttpTransport(); HttpRequestFactory

gdata Unknown authorization header - started 12/11/13

僤鯓⒐⒋嵵緔 提交于 2020-01-02 08:25:20
问题 The google calendar sync had been working fine for a long time now suddenly starting yesterday we started getting the following error. I saw that this has happened in the past and google engineers (SRE) had to apply a patch to fix this. com.google.gdata.util.AuthenticationException: Unknown authorization header 回答1: Google Account Authentication APIs ( ClientLogin, AuthSub and OAuth 1.0 ) are deprecated as per deprecation policy. http://googledevelopers.blogspot.com/2012/04/changes-to

How to get user profile on Google API using the JAVA library?

怎甘沉沦 提交于 2020-01-02 04:25:06
问题 I have a Java ClientRequest to the Google API that returns a json containing the profile based in an access_token. The URL is: https://www.googleapis.com/oauth2/v1/userinfo?access_token=ya29.1.AADtN_VALuuUTBm8ENfNTz8s... And the response is: { "id": "111223344556677889900", "email": "myemail@gmail.com", "verified_email": true, "name": "My Name", "given_name": "My", "family_name": "Name", "link": "plus.google.com/111223344556677889900", "picture": "photo.jpg", "gender": "male", "locale": "en"

“Cannot find DriveId. Are you authorized to view this file?”: Even if EXISTING_FOLDER_ID is set manually

依然范特西╮ 提交于 2019-12-30 11:16:09
问题 I am having a look at here from github. I can create a file and a folder successfully by reading the code provided in github. But I am not being able to edit the file or create a file/folder in any specific folder. The main problem would be using emulator, but I am not sure. I am using GenyMotion I have also copied the ID of a file/folder using showMessage("Created a file in App Folder: " + result.getDriveFile().getDriveId()); and showMessage("Created a folder: " + result.getDriveFolder()

Using Google API Java Client on Android, a POST request does not seem to authenticate with Google App Engine app using OAuth

和自甴很熟 提交于 2019-12-30 10:35:23
问题 I have an Android client that needs to authenticate with a python Google App Engine app using OAuth. I followed this article. And was able to successfully do so using an HTTP Get Request. The Android client uses the package com.google.api.client to accomplish this: OAuthHmacSigner _signer; HttpTransport TRANSPORT = new NetHttpTransport(); _signer = new OAuthHmacSigner(); _signer.clientSharedSecret = CONSUMER_SECRET; // STEP1: get a request token OAuthGetTemporaryToken requestToken = new

drive.changes().watch returns GoogleJsonResponseException: 401 Unauthorized without any message

旧街凉风 提交于 2019-12-30 07:29:31
问题 I'm trying to watch for changes in Google Drive, and getting 401 Exception. Searching here, i found that people have detailed messages, why they are not unauthorized though i have nothing. Here the code i use: public static void main(String[] args) { try { httpTransport = GoogleNetHttpTransport.newTrustedTransport(); dataStoreFactory = new FileDataStoreFactory(DATA_STORE_DIR); // authorization GoogleCredential credential = GoogleCredential.getApplicationDefault() .createScoped(DriveScopes.all

Android NetworkOnMainThreadException inside of AsyncTask

倖福魔咒の 提交于 2019-12-30 07:21:06
问题 I have a problem on ICS when I try to use google calendar api. To get a list of events, I have a AsyncTask and inside doInBackground() I make the service calls but still I receive the NetworkOnMainThreadException error. Here is my code: I call my AsyncTask like this: new GoogleCalendarEvents().execute(new Object()); And my AsyncTask looks like this: private class GoogleCalendarEvents extends AsyncTask<Object, Object, Object> { @Override protected Object doInBackground(Object... objects) {

Google Calendar API OAuth2 Troubles on Android Honeycomb

南笙酒味 提交于 2019-12-29 05:28:08
问题 I am working on an Android Honeycomb (v3.0) application that has a requirement of communicating with the Google Calendar API. I would like to allow my application to access a particular Google account's Calendar data in order to read and create events. Unfortunately, I ran into a problem with authorization using OAuth2. Here's what I have so far: 1) The Google account whose calendar I would like to access is registered within the Android device I am working with. 2) I enabled the Calendar API

Write to GoogleSheet via API with Java

旧巷老猫 提交于 2019-12-29 01:34:13
问题 I am trying to write a value to a cell with Google Sheet API with Java. For reading I used guide from Java Quickstart which worked fine for me. For writing to Google Sheet I use: service.spreadsheets().values().update(spreadsheetId, "Sheet1!A4:H", response).execute(); This function outputs the following error while run: com.google.api.client.googleapis.json.GoogleJsonResponseException: 403 Forbidden { "code" : 403, "errors" : [ { "domain" : "global", "message" : "Request had insufficient