Access Google Calendar in IOS using Service Account - ios

I need to access a NON-public Google calendar WITHOUT requiring the user to log in or even have a Google account.
I created an Android app that accesses a Google calendar using a service account:
GoogleCredential credential = new GoogleCredential.Builder()
.setTransport(httpTransport)
.setJsonFactory(jsonFactory)
.setServiceAccountId(serviceAccountID)
.setServiceAccountScopes(scopes)
.setServiceAccountPrivateKeyFromP12File(licenseFile)
.build();
com.google.api.services.calendar.Calendar.Builder builder = new com.google.api.services.calendar.Calendar.Builder(httpTransport, jsonFactory, credential);
builder.setApplicationName(appName);
com.google.api.services.calendar.Calendar client = builder.build();
com.google.api.services.calendar.Calendar.Events.List list = client.events().list(calendarID);
list.setMaxAttendees(maxAttendees);
list.setTimeZone(timeZone);
list.setTimeMin(startTime);
list.setTimeMax(endTime);
list.setOrderBy(orderBy);
list.setShowDeleted(showDeleted);
list.setSingleEvents(true);
Events events = list.execute();
This included:
Creating a project in the Google App console
Creating a Service Account
Giving the Service Account access rights to the Google calendar
It works GREAT!
I need to do the same thing in IOS. I have read every question/answer I can find on this topic and have found VERY different answers. Many say that Google hasn't allowed this in the IOS SDK because service accounts are intended to be used by server-based applications. I don't agree since the functionality I need is available in Android. So, now what?
The use case is this:
My IOS app needs to access a Google calendar. That part is not too tough if you are okay with using OAuth. My problems with this approach are:
Requires to user to have a Google account. Many of my users are Apple-Only. I can't require them to get a Google account just to use my app.
I can't make the calendar public. So, I would need to give access to every new user. I guess I could do that with a web-based application but this doesn't fix the problem (refer to previous problem - no Google account).
I really need to be able to query the events in the NON-public Google Calendar WITHOUT the user needing a Google account. The solution IS using a "Service Account" (I think).
I read one question/answer that said this is possible but the solution was never posted. (How to list Google Calendar Events without User Authentication)
HELP!!!!

The official documentation suggests that if you want to handle Calendar API (for example), you'll have to have a Google Apps for Work (source).
If you have a Google Apps domain—if you use Google Apps for Work, for example—an administrator of the Google Apps domain can authorize an application to access user data on behalf of users in the Google Apps domain. For example, an application that uses the Google Calendar API to add events to the calendars of all users in a Google Apps domain would use a service account to access the Google Calendar API on behalf of users.
Once the prerequisite is met, you can try to just call the REST URLs of Calendar API based on your implementation (since there seems to be no iOS support or samples available in the documentation).

Related

Google Cloud Platform programmatically create user account via API

I'd like to create programmatically via API a new Account for accessing my Google Cloud Platform.
I'm already doing it for GSUITE (provisioning users via OAUTH), is it possible to do the same also with Google Cloud Platform?
Is it possible to do it for an "non-google" external account maybe with an invitation on the email?
Having already the setup for OAUTH in GSuite, is it possible to use the same token / account to perform also this operations (maybe assigning more scopes)?
Are this API (https://cloud.google.com/iam/docs/granting-changing-revoking-access) the only available?
Updating the IAM policy is indeed the only way to use an API to grant access on a "pure GCP" level.
However, you can give a role in a project to a Google Group (or a few, if you require different access levels), and then simply manage the group using the GSuite Admin SDK.

How do I authenticate Google Calendar API v3 without user interaction?

I'm using Google and external calendar sync (console application). I've tried several ways to connect to my calendar in Delphi. In the latest version of the Google API, you can choose two options:
API Key (public calendar)
OAuth2.0 (private calendar)
The calendar is not public. I looked at a couple of examples, but everywhere the need for user interaction. I want to identify myself with no user interaction. How can I do that?
I don't know about using it in Delphi but there is a client API library for java, python... I've already used the java one and it's clearly explained how to use it in the documentation.
Google Calendar API 3 Doc page:
https://developers.google.com/google-apps/calendar/
However, the service asks you to be authentified to used it (which is your problem if I understand it well, you don't want the user to have to authenticate). So I suggest you to have a look on OAuth2.0. https://developers.google.com/google-apps/calendar/auth
Here are some simple of using google-api-java-client for exemple : https://code.google.com/p/google-api-java-client/wiki/OAuth2
And you should look more precisely at Google OAuth service account possibilities.
Service Account with OAuth2.0. (See here : https://developers.google.com/accounts/docs/OAuth2#serviceaccount).
It will provide a service account for your application, from which you will be able to handle calendars for your app.
And here you will find a sample showing how to do it with Java. (https://code.google.com/p/google-api-java-client/wiki/OAuth2#Service_Accounts). But maybe this is the public API Key you are talking about... Not sure I remember properly.
I hope this will help you to figure out how to do it.

Ruby Google API key and analytics

I am creating a Ruby application that needs to access dozens (maybe hundreds) of different Google Analytics accounts, query each account, and then generate a report based on the results. I know I can achieve this using Googles API client ( http://code.google.com/p/google-api-ruby-client/ ) and Oauth, but that would require manually generating a set of keys and credentials for each analytics account which is not really feasible. I'm wondering if there is another way to access google analytics (perhaps using the API Keys?) that bypasses the need to generate credentials manually.
After quite a bit of tinkering, I've finally stumbled upon a solution to my particular problem. As it turns out, I don't need to create a separate Developer account for each Analytics account I want to access. I can simply create a single Developer account, and then add that Developer accounts' email address to the set of users that are able to access the Analytics account. This will allow me to access multiple Analytics accounts using the same Developer account.
Yes, it will still require quite a bit of work adding the Developer email account to hundreds of Google Analytics accounts, but it pales in comparison to creating a separate set of Developer credentials for each Analytics account.

Confusion on the Old Google Data AP, new Google API, and the Google Apps Marketplace

Currently Google is migrating their old Google Data API to the new Google API.
When we do API queries over the old Google Data API, we usually use Zend Framework and the given consumer key/secret to do the authen/autho, which is fine.
Question is, is it possible to use the given consumer key/secret (from the Google Apps Marketplace listing) and the new OAuth 2 Library to call the API? What I have been having is the error message redirect_uri mismatched issue and obviously Google Apps Marketplace provides no way to change this value. Even though they had provided a link for us to go to the API Console from the listing page, I cannot see the OAuth 2.0 options in my API Access page at all.
Did I missed out anything?
If let's say I need to use the Google Apps Admin Settings API, does it mean I need to separately create a new OAuth 2.0 API Access in the API Console, then, when I need to access user data, I need to do the Auth flow again using this new consumer key/secret/redirect? I can't set this permission in the Listing Manifest? (Not supported?)
Thanks for the clarifications!
Google Apps Admin Settings is not yet migrated to the new google-api, AFAICS. Check out this list : http://code.google.com/p/google-api-java-client/wiki/APIs ;
you can however use the new google-api client libraries but you have to roll your own XML model for the given API, it is not so hard, I did a similar thing for the Contact API;
The consumer/key secret can be re-used normally if it is sufficiently scoped. A related project for your market app is automatically created in the Google Api console from what I remember..

Google Places API in iOS application

Let me share my findings before asking the question.
Google Places API documentation says:
"Note: To use the Google Places API you must first request a Maps API
client ID and cryptographic key which you must use to sign your
request URLs. For information on signing URL requests, please see the
URL Authentication documentation within the Web Service APIs home
page."
The Google Places API is still in developer preview.
http://code.google.com/apis/maps/documentation/places/
We need a Client ID (required) and a Signature (required) to use
the Google Places API.
http://code.google.com/apis/maps/documentation/webservices/index.html#URLSigning
And, to get the Signature, we need a Google Adsense account to get
Adsense publisher id (required).
http://gmaps-ws-console.appspot.com/
You can find the requirements to use the Google Places API here.
http://code.google.com/apis/maps/documentation/places/index.html#Requirements
The Signup page for Google Maps API suggest that, "Your service
must be freely accessible to end users. To use Google mapping
technology in other types of applications, please use Google Maps API
Premier. See this FAQ for more information."
http://code.google.com/intl/it-IT/apis/maps/signup.html
Now, here's what i want to know.
I'm planning on using Google Places API in my iOS application. I don't
want to use Adsense. Can i still access the Google Places API for
free? How?
If i can't access the Google Places API for free, what are the costs
associated with using this service, and the available payment models?
I wasn't able to find any particular resources for this information.
Here's a specific scenario. What if my iOS application is free. The
free version uses Google Places API. But... my iOS application has
some additional features which are exposed using In-app Purchase (paid
features). The paid features do not use Google Places API. Is this
acceptable?
We opened up the Google Places API to all developers this week at Google I/O and simplified the Terms and authentication:
http://googlegeodevelopers.blogspot.com/2011/05/places-everybody-show-is-about-to-begin.html
You no longer need to sign your requests, but instead just use a key obtained using the Google APIs console. An AdSense ID is no longer required, but you will need to go though a credit card based identity check in order to upgrade from 1,000 to 100,000 request per day.
You can use the Places API in mobile apps that are free or sold online through a mobile app store such as the Apple App Store or Android Market. For fee desktop apps however will require a Maps API Premier license which will be offered once the Places API graduates from Google Code Labs.
For information on getting started, see the docs:
http://code.google.com/apis/maps/documentation/places/
HTH,
Thor

Resources