How to use google analytics Api without using google account - google-analytics

we are provide saas plugin to our customers, we need to get events for each customer's website without creating seperate GTM container and GA property , All the process will takes place in background.
There should be no login requried ,insted we will send the username and password to Google Aalytics through code(JavaScript).
so we need to use google analytics Api without google sign in
is there a way to do this

we are provide saas plugin to our customers, we need to get events for each customer's website
If you want to connect to the analytics accounts for your customers websites they you need to be authorized to access their private data.
no login requried ,insted we will send the username and password to Google Aalytics through code(JavaScript).
You can not login to anyones google account using login and password that was called client login and google disabled that in 2015. You will need to use Oauth2 request consent and gain authorization to access their private data.
so we need to use google analytics Api without google sign in
Sign in is authentication, the Google analytics api operations on authorization. The user needs to consent and grate you authorization to access their data.
is there a way to do this
No you can not access private user data without the owner of that data authorizing your access to that data.

Related

Connect with GA4 using any Gmail account credentials, select property and fetch analytics data in website without any key

I have requirement of creating website in c# to integrate the GA4. On which I can connect with GA4 API with any gmail account (userid/password), then select the property account from the list and get respective data without using any specific client key. Any help would be greatly appreciated.
On which I can connect with GA4 API with any gmail account (userid/password)
You cant this is / was called client login google shut this down in 2015. In order to access private user data you must use oauth2 to request consent of the user in order to access their data.
without using any specific client key.
You cant oauth2 requires that your application be registered and verified by google in order to access private user data. Then in order to request authorization you will need to use your client id and client secret.
Any help would be greatly appreciated.
Start looking into how to the Google analytics data v1 api

Google Calendar API v3 - authenticate with application owned (non-real user) account

I've been looking into Google Calendar API as a way to manage calendar/event information for my application. It looks like Google Calendar API is setup to connect to a Google user's account. After you have access to the user's account you can add/update/manipulate calendar and event information. I want this same functionality but on a "user account" that is virtual.. not owned by a real user but an account created specific to my application to use. Is this possible?
The docs mention Google will show a consent page to the user to integrate with the users calendar, how would I go about coding the authentication for my calendar if I (the application) owns the account and calendar?
You could use a service account, which will belong to a project in your dev console, and you can give it credentials to access its own calendar.
See Using OAuth 2.0 to Access Google APIs

Google calendar api authentication in Google Actions

I want to be able create calendar events in my Action that runs through Google Assistant.
Right now I was able to modify this Quickstart guide (https://developers.google.com/calendar/quickstart/nodejs) and use it in my current Dialogflow fulfillment. However, it's a little tedious to have the user have to copy and paste the authentication code after allowing Google Calendar access. Are there any better ways to do this that doesn't require the copy-paste flow? Thanks in advance!
Use Account linking with Google Sign-In
https://developers.google.com/actions/identity/google-sign-in
Then send a card to the user device with a link to authorise Google Calendar access. Store the authentication code securely against the user. Use the authentication code to make requests.
Broadly speaking, the approach you can take is to use Google Sign-In, as outlined in this SO answer: Google Home Authorization Code and Authentication with Google Account.
With this scheme, you use a website to get the user to authorize your use of the Calendar API scope, and you store the auth token against their UserID. Then you use Google Sign-In with the Assistant to get that ID. This works well if they go to your web page first, but not as well if they go to the Assistant first.
You can also setup an OAuth server that lets users sign-in using Google Sign-In on a web page (or use something like Auth0 and, as part of that sign-in, get authorization for the Calendar scope. Then use OAuth Account Linking in the Google Assistant to get an auth token which you can use to get the user's ID. You can then use this ID to lookup the authorization token.

How can I access the Google Calendar API through Google Actions and Dialog Flow

Referencing this post
, I tried to create an access token for my Google Actions. I enabled Google sign in, and end up with a user-id. The top post says "You can combine this with a web- or app-based Google Sign-In to get their permission to access OAuth scopes if you need to access Google's APIs" but I honestly have no idea how to do that. What I'm trying to do is get an access token from Google Actions/ Dialog flow to send to my server-end code in order to make a successful API POST request to Google Calendar API.
The post you reference that points to another StackOverflow answer that discusses the approach. It basically says that you need to combine two things to do what you want:
You use Google Sign In on a web page to let the user authorize you to access the calendar on their behalf.
You probably should use the hybrid flow so the access/refresh tokens are only handled on the server side - not in your web client.
Your server will store the access/refresh tokens in some way so you can use them as part of your Action later.
You will use Google Sign In for Assistant to authenticate the user when they connect through the Assistant and determine if they have already authorized you to access their calendar. If they have, you'll be able to get their access/refresh tokens out of your store and access their calendar.
You can't do it completely through AoG/Dialogflow because there is no way for the user to grant OAuth permissions to you by voice alone - this is why you need to direct the user to a web page for them to grant you permission to access their calendar.

Retrieve Google Calendar owner's email address

Is it possible, with the Google Calendar API / Zend Gdata, to get the user's google email address, after he successfully authenticated with AuthSub and I have an access token?
I have a problem with some users having multiple Gmail and Google Apps accounts, and then not remembering which one they've used to Sync with my service and having the impression that the sync doesn't work. I'd like to display them the Google Account they have first authenticated with.
Have you tried the experimental settings API? It looks like it returns the user's name and email address in the author section.

Resources