So I am trying to sync to google docs, without having to ask the user for his credentials. I use this code to get an auth-token:
AccountManager mgr = AccountManager.get(activity);
authToken = mgr.blockingGetAuthToken(account, DocsService.DOCS_SERVICE, true);
This returns a auth-token that looks well-formated. So on my DocsService I run:
service.setAuthSubToken(authToken);
However, when I try to use the API I just get a AuthenticationException. Any ideas on how to approach this error?
edit: I do have the USE_CREDENTIALS permission.
The problem is that the returned token is a ClientLogin token, not an AuthSub token. An even bigger problem is that the GData Java Client library does not officially support Android. We recently added a note on the home page of the GData Java Client library that for Android we recommend Google API Client Library for Java instead.
Two samples come up mind that would be helpful for you for getting started with Google API Client Library for Java: calendar-v2-atom-android-sample and docs-v3-atom-oauth-sample
Disclosure: I am an owner of both the GData Java Client library and Google API Client Library for Java projects.
You might also want to take a look at Yaniv's Google I/O 2011 Session slides/video for reference on how to access the GData APIs on Android.
http://www.google.com/events/io/2011/sessions/best-practices-for-accessing-google-apis-on-android.html
As Yaniv explained, Gdata Lib doesn't work in Android. I wasted several hour with no result. It looks pretty weird, its Google's product and still not supported in their own platform (Android).
Anyway I have developed a Client Library which works on Android. I am managing the project on Google Code-
http://code.google.com/p/google-spreadsheet-lib-android/
You can give a try.
Related
I am working on a project on android and I want to implement the functionality of my application on an API written in Node JS and use it with HTTP requests.
I am searching for an (open source) HTTP API (CRUD System) that I can use in my android application in order to make HTTP requests to my API (GET, POST, PUT, DELETE).
What are you suggesting me? Which are the best solutions?
Thank you
I recommend OSS "Fuel".
https://github.com/kittinunf/Fuel
I created a sample application of API request using Fuel.
https://github.com/y-okudera/FuelSampleApp
I hope this will be of some help.
I can't find this question answered (or addressed) anywhere else, so maybe I am just missing something really obvious, but I have followed these official GCM steps to get GCM added to my Android project and have got stuck.
My first issue is that the documentation states...
...copy the Server API key. Before running the app, you'll need to add this as the value of API_KEY in line 31 of GcmSender.java.
...but what/where is GcmSender.java?
And, my main question, how/where do I specify the URL of my application server in my Android project?
NB - I am using Android Studio. I haven't created my application server yet, but will be doing so with a PHP script that uses HTTP messaging.
The first step is creating a new project at Google Developers Console . At this step, for simplicity, you just need to take note of 2 values: Project Number, which will be used as SENDER_ID in a client project; and API server key (created at Credentials), which will be used as API_KEY in a server project.
You can find more at my simple guide at the following questions:
Adding Google Cloud Messagin (GCM) for Android - Registration process
How to implement a GCM Hello World for Android using Android Studio
Hope this helps!
Have just found it.
In the RegistrationIntentService.java file, there is an empty sendRegistrationToServer(String token) method, so the URL of my application server (and the rest) needs to go in there.
I'm making an Android app and am trying to use the Foursquare API. I started to use the Foursquare-recommended library, easyFoursquare4Android.
I registered my Foursquare app at https://foursquare.com/developers/apps. I Changed the CLIENT_ID and CLIENT_SECRET constant values in the easyFoursquare4Android library.
How can I make userless requests such as getting nearby venues with the easyFoursquare4Android library?
To get access to the API, you must call the AccessTokenRequest class, which tries to get an access token.
I found the userless access section in the Foursquare API Docs, which says that
"To make a userless request, specify your consumer key's Client ID and Secret instead of an auth token in the request URL."
Should I change the library since it doesn't look like it supports userless access?
Edit:
I made an issue in the easyFoursquare4Android library GitHub Repository.
The library seems to rely on having an access token.
You possibly can override that behavior by editing the hasAccessToken method to return true in EasyFoursquare and EasyFoursquareAsync.
I am a little confused by these APIs. I am trying to integrate Google+ with my Android app and I am struggling a little. I have been successful at logging in a user using OAuth2, created a Verifier, obtained an accessToken and made a request to Google+ API.
Here is my line of code requesting to see the user information:
OAuthRequest request = new OAuthRequest(Verb.GET, "https://www.googleapis.com/plus/v1/people/me");
This successfully returns a jSON object containing my information/public.
Whenever I change the endpoint to this:
"https://www.googleapis.com/plusDomains/v1/circles/p4643b3a289c42c44"
attempting to use the PlusDomains, I get a forbidden message.
What I really want to do is manage circles for a user (simply add a page to their "Following" circle. That is all I need.
What am I doing wrong? Am I trying to use the wrong endpoint? Does Google+ API allow me to do POST requests?
Every piece of information is helpful.
Thanks in advance!
Google+API and Google+Domains API are different APIs (activating/allowing one does not activate/allow the other).
The Domains API can be considered as a more powerfull (more functionnalities) than Google+API.
See comparison of the two API here on the official doc.
Link here
I try to use Google oauth to authenticate users on my android app.
Then I would like to send it to my app server so it can connect at any time with Google calendar.
I tried to use
GoogleAuthUtil.getToken(getApplicationContext(), mAccountName, mScope);
Following this article:
https://developers.google.com/accounts/docs/CrossClientAuth
When I use it with scope
mScope = "oauth2:https://www.googleapis.com/auth/calendar https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile";
I get a token, which is valid for an hour
But when I try to get an authorization code (so I can get a refresh token that is valid for longer time, using
mScope2 ="oauth2:server:client_id:{CLIENT_ID}.apps.googleusercontent.com"+ ":api_scope:https://www.googleapis.com/auth/calendar https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile";
I receive either "invalid_scope" or "Unknown" exceptions.
What am I doing wrong?
EDIT:
OK, After creating a new app on google API console and adding plus.login to the scope I get a code, but for some reason my server can't resolve this token. When tying to resolve server gets an error about the redirection URL.
BTW, When I do the web flow with same parameters it works.
OK, found the solution, I expected Google to have a lot better documentation about working with Google Oauth and Android. A few things you have to know to work with Android and offline token
When you create google Client ID Don't create a service application before you create a web application
Must include https://www.googleapis.com/auth/plus.login in your scope
The weirdest, to resolve the one time authorization code on my server, I had to use the redirection URL from the Android client ID details (which doesn't even look like a url) and not from the Web client details on Google API console.
That scope string is only documented to work when passed to GoogleAuthUtil(), see http://developer.android.com/reference/com/google/android/gms/auth/GoogleAuthUtil.html, on Android. But it would be cool if it worked on iOS too; our infrastructure there is a little behind where we’re at on Android.
I have had the same issue then i realised that my app is not published and is in debug mode, so i had to add test users to the Google project -> Consent Screen, then i was able to fetch the token for the added test user.
You just need to follow the correct steps/format for specifying the scopes. Find them here https://developers.google.com/android/guides/http-auth#SpecifyingScopes