Flutter Google Calendar Api - google-calendar-api

I am new to flutter and trying to find a way to pull Google Calendar events into my application. I am following this https://docs.flutter.dev/development/data-and-backend/google-apis
to try and understand how to do this. The example is for youtube but I am trying to adapt for Google Calendar. I followed the instructions and have enabled the api in Google. I also have searched for tutorials on how to do this and most examples authenticate a client like so:
clientViaUserConsent(_clientID, _scopes, prompt).then((AuthClient client)
However, that is not what the documentation I see indicates.
var httpClient = (await _googleSignIn.authenticatedClient())!;
I am now getting an error that my scopes are not correct.
scopes: <String>[
'email',
CalendarApi.calendarScope,
]);
I guess I am looking for a 2022 example to pull google calendar data into my flutter app. I appreciate any help. Thank you.
I tried searching for answers and trying various implementations. I am at a loss to find the solution.

Related

Google Calendar API: calendar.events.freebusy vs calendar.freebusy

I have seen the description provided for these scopes in the console, but they are not clear for me.
What is the difference between these two scopes?
OAuth 2.0 Scopes for Google APIs
Calendar API:
It would be important to clarify that all necessary scopes for any Google application can be found here:
https://developers.google.com/identity/protocols/oauth2/scopes
There are 5 scopes over the official documentation that allows you acess Calendar and their properties, plus another 2 that are used for managing Calendar Resources from Google Admin for organizations. This means that both of those are old and deprecated scopes (Potentially from V2 or were removed due to being no longer necessary and packed under any other ones from the documentation):
https://www.googleapis.com/auth/calendar.event.freebusy
https://www.googleapis.com/auth/calendar.freebusy
If you try to run or access any of these scopes you would be prompted with an alert similar to this:
As one final thing that can easily help you with deatils on what scopes are needed to query Freebusy information, you can review the authorization scopes needed to run it here:
https://developers.google.com/calendar/api/v3/reference/freebusy/query

Is there a way for someone to add an event from my app to my Google Calendar? (e.g., similar to Calendly?)

I am somewhat new to this, and I've been building an app on low code platform Bubble.io. I've recently been trying to learn the Google Calendar API to integrate a new function into my app.
Here's what I'm trying to enable: a Calendly-esque function where a user of the app can connect their Google Calender. The user can then send a url to non-users of the app to book time with the user on the user's Google Calendar.
Here's my question: how can someone book time on another persons calendar without making the calendar public? From what I've been researching the calendar has to be public to book without authorizaton, but Calendly manages to do this without making a calendar public.
Thank you in advance to anyone who takes time to read / respond!
if you're still trying to solve this, yes this is possible. Two ways I know this can be done:
Nylas, which would also allow you to integrate with Microsoft/Outlook calendars using the same API calls https://www.nylas.com/
Google Calendar API https://developers.google.com/calendar
Both of these will require you to set up OAuth functions, and might require some custom javascript actions (but also might not). When I tried to set up Nylas using Bubble several months ago, it was not possible to create a Bubble OAuth flow using the API Connector with Nylas. Instead, I had to create a custom flow and it was quite confusing to set up, but eventually worked to do what you've described.

getting firebase campaign information from flutter app

I'm writing a flutter app and I'm trying to find out how to fetch campaign information from the flutter app for the current user.
so In firebase console when I go to Conversions -> Network Settings
and I generate a Click campaign URL with some relevant values to Source, Medium, Campaign, Ad Network Type and Creative.
now when the user installed the app from that click campaign and executed the app, I want to be able from flutter to be able to fetch these parameters.
any ideas how to do so?
I thought i'll find it in the flutter analytics API but so far no luck.
any information regarding this issue would be greatly appreciated.
thanks!
There is no public API to get the campaign information or other data from Google Analytics for Firebase.
The only ways to get analytics data from Firebase are:
exporting the raw event data to BigQuery, and doing further/custom analysis there.
exporting the data from the charts to CSV by clicking the Download CSV option from the ⠇ overflow menu.
As far as I know neither of these exports the definitions of your campaigns however. The best I can think of is to replicate the parameters in your app. I realize that's not ideal, so hope someone knows of a better way.

Connecting to Youtube Analytics API using R

I am trying to pull data from Youtube Analytics API using R and have hit a wall. I'm getting a Status 403 error. I can confirm that:
I have tried logging out of all accounts, rebooting, re-authenticating and then logging into 1 account and it didn't work
I have tried using just the https://www.googleapis.com/auth/youtube.readonly scope (which is supposed to be correct) and all youtube analytics scopes are authorized within the app (each with their own credential key), it didn't work.
I have tried authenticating from different browsers, it didn't work
I can confirm that the call worked from https://developers.google.com/apis-explorer/#p/youtubeAnalytics/v2/youtubeAnalytics.reports.query.
UPDATE
I have found the solution and updated the code to what is now working
scopes<- c('https://www.googleapis.com/auth/youtube.readonly')
endpoint<- oauth_endpoints('google')
youtubeapp<- oauth_app(appname='Youtube Analytics API',
key=client_id,
secret=client_secret)
youtube_token<- oauth2.0_token(
endpoint= oauth_endpoints('google'),
app = youtubeapp,
scope = scopes)
raw_data<- GET(paste("https://youtubeanalytics.googleapis.com/v2/reports?dimensions=",dimensions,"&endDate=",enddate,"&ids=",ids,"&metrics=",metrics,"&startDate=",startdate,sep=""),
config=youtube_token,content_type('application/json'))
content(raw_data, as= 'text')
I have figured out that access permissions are dictated by Youtube (not API IAM), so for example even though my personal email is owner of Brand account and API I still need to authenticate the call using the Brand Account or it won't work (I get 403 error for personal email). I tried switching my Youtube channel from Brand to personal and then my personal email worked. However, I need it under the brand account, so I have switched back.
I will leave this code up regardless because I found that good examples using R were lacking, I hope you find this useful.

How to read a public Google calendar from a mobile app without authenticating?

I need to read many Google public calendars from an iOS app. I don't want to require users to authenticate.
The docs and samples from Google all seem to assume an app is reading a user's private calendar, which naturally would require authentication.
I see something called a Service Account mentioned, but it's not obvious that it should be used in mobile apps.
I don't need to use one of the SDKs if I can just retrieve JSON from some URL.
This question has been asked on StackOverflow in the past, but I haven't found an answer which still works. Google changed their API in 2014.
How can I read a public calendar from a mobile app without authenticating?
The answer was given in the comments by #Mr.Rebot and #Vipin Sharma. Just use this URL:
GET https://www.googleapis.com/calendar/v3/calendars/{YOUR_CALENDARID}/events?key={Y‌​OUR_API_KEY}
One can get an API_KEY from the Google developer console. It's an option I overlooked at first.

Resources