How to get Authenticated user's Google Ad Account ID using Google Ads API v0 using a REST API? - rest

I have been trying to figure out after referring to their official documentation (Google Ads API Document) which is not clear enough
Here is what I have tried till now.
I have created an app where users can log in with their Google Ad words account. I need to fetch their Ad performance reports via REST API.
To make an API request to fetch performance reports, we need the Google Ad Words Account ID of the authenticated user. Currently, as I am testing it with my personal account, I can login to my Ad words Console and get the Ad Words Account ID. But, how do I fetch the Ad Words Account ID dynamically for other users who authenticate via my App?
I tried looking for a way in their official documentation. But I couldn't figure out.
Could someone help me with the REST API URL which needs to be called to fetch the authenticated user's Ad words Account ID.

In addition to previous answer, I guess this is what you are looking for:
https://developers.google.com/adwords/api/docs/guides/first-api-call#create_test_accounts
It explains how to setup Google Ad Words API and get your ID.

According to the documentation here Account overview, you need to list the customers to get the ID. For each user that logs in as long as they do not have access to multiple accounts you should get a single customer and their ID.
CustomerService
CustomerService provides information about your accounts. It has a
getCustomers() method that takes no arguments and returns a list of
Customer objects containing fields such as customerId, currencyCode,
and dateTimeZone. CustomerService also has a mutate() method that can
be used to update various attributes of a customer, including the
autoTaggingEnabled and conversionTrackingSetting fields.
If no clientCustomerId is specified in a request, the response will
contain multiple entries if more than one account is directly
accessible by the authenticated account.

Related

How to distinguish using google api between google suite admin and google suite business admin

Regular GSuite admin cannot create new team drive (only business admin can) I need to distinguish between regular GSuite admin and business GSuite admin via API.
I'm using G Suite admin SDK in java to retrieve google user, however there is no flag or variable that can help me to differ between the two.
Is there a way to do it?
(AbstractGoogleClient.Builder) client;
client.login(Directory.Builder.class);
Directory.Users.Get request = ((Directory) client.users().get(EmailOfAdmin-RegularOrBusiness);
User user = client.execute(request);
Regular G Suite Admin API uses to retrieve a user:
GET https://www.googleapis.com/admin/directory/v1/users/userKey
wherein, userKey can be the user's primary email address, the unique user id, or one of the user's alias email addresses.
While with G Suite Business, files belong to a team instead of an individual. Each user in your organization can store unlimited Gmail messages, Gmail Photos and files in Drive.
The Drive activity report returns information about how your account's
users manage, modify, and share their Google Drive documents.
See API Reference for the information about request's query strings and response properties. For information about specific events related to to Google Drive, see Drive event names.
Look into the RoleAssignments.list endpoint. This should give you information about the roles associated with a certain user and what kind of admin they are.
Check out this page for more information on Roles: https://developers.google.com/admin-sdk/directory/v1/guides/manage-roles

How to retrieve a list of users from VSTS REST API?

Using the REST API, I want to get a list of users for an account, I had a look through the reference but couldn't find a way.
Using a GET request I want to return:
id (GUID)
displayName (text)
uniqueName (text)
for an account where account is https://{account}.visualstudio.com/DefaultCollection
There is no such REST API for now.
But I posted an user voice Get users belongs to a VSTS account by REST API, you can vote and follow up.
Your question is not clear. But looking at the VSTS documentation, to retrieve accounts you can do curl based on the memberId
Here is the documentation for it.
https://www.visualstudio.com/en-us/docs/integrate/api/shared/accounts

Cannot retrieve the reach estimate for some Facebook ads (from the API)

The API lacks some clear explanations on retrieving the reachestimate for either an ad account or an ad. I have made sure that:
I am an admin/ or added to a Facebook app
I have a paid advertising campaign
The adaccount ID is added in the Settings Advanced panel of the Developer App page
I've been trying to:
In Graph API Explorer, retrieve the data by query expansion: me?fields=adaccounts{campaigns{adsets{ads{reachestimate}}}}. However, I always get one of the following (randomly):
Still in the explorer, retrieve it by direct access: act_{adaccount_id}/reachestimate I get this, even if I am 100% sure the ad account is added in the Advanced Settings panel:
Both of 1 and 2 in the iOS project. I get this: com.facebook.sdk.core error 8
Test it by curl with the example from here. I get this (the same with the one from point 2): The ad account is not enabled for usage in Ads API.
Just as a further note, for point 1 that's not the whole query, but I didn't write the adjacent fields because they would've been redundant for the purpose of this question.
I simply need to retrieve the ad accounts, the campaigns, the ad sets and the reach estimate simultaneously in the same query. It seems like a dead spot for me. Do you have any suggestions? Can you show me a Graph API explorer working example? Or, if what I'm asking is impossible, can you simply show some code that works?
Are you app and ad account owned by the same person?
Facebook Ads API has tiered access. https://developers.facebook.com/docs/marketing-api/access
A newly registered app is in Development Tier and can only access the user's own ad accounts. You need to make some API calls on your own ad account for testing in order to get promoted to Basic Tier and manage other people's ad account.
Apparently, I got:
Please reduce the amount of data you're asking for, then retry your request.
Because the query was to broad. Those 'adjacent' fields actually triggered a massive query, so the solution was to either:
Put a limit(1) on the campaigns.
Individually retrieve the reachestimate for each adset.
I chose the latter because it suited my needs, but it's up to you which solution works better.

Get page visitors from google analytics API

Reading Google Analytics API docs is like diving into Mariana Trench... so hoping to get some help here.
I have a website that users will visit one page per visit (most of the time). I've placed google analytics script on each page (can view reports in my GA account) and now want to write a "reporting page" on which to display information about "per page usage":
page1: 100 visitors, countries, OSes, ...
page2: 125 visitors, countries, OSes, ...
I want to get this info from API.
Could some one please point me to the right pages of the docs, from the very beginning?
For I can't understand even why I should use 2-step OAuth authorization there (or shouldn't I?) - since I'm writing this report for my own site on which I have already placed google scripts thus authorizing everything.
Thank you.
What i am thinking is that I could have a Webapplication with your pages listed. Web application itself is authenticating and querying the result on when user try to find statistics of particular page.
You should follow
1. Register Service account and get authentication key file
2. Register email account viewed in along clientid email a screen in google analytic users as admin level user
3. Use ga-dev-tools.appspot.com/explorer for query building
4.Implemenation needs
a) First Authenticate with the key
b) Get profile id and pass it to the fetching method
c) Fetch data of the query

Google + Domains API domain wide delegation

I am trying to write a powershell script that uses the Invoke-RestMethod to connect to the Google + Api and authenticates with a service account that has been granted domain wide delegation of authority. Then I want to use a list names to retrieve the google + userid and from there I want to create a circle and insert all of those users into that circle.
The main issue I am having is retrieving the userid for the list of users, I think I would be able to figure the rest out once I had that piece.
Thanks
The Google+ Domains API is unique in that it allows you to make API calls using email addresses in the place of the Google+ ID. This means that if you have a list of users within your domain, you may make API calls on their behalf, by specifying their email address when building the authorized API client.
In Java, this is done by calling setServiceAcountUser on your GoogleCredential:
GoogleCredential credential = new GoogleCredential.Builder()
.setTransport(httpTransport)
.setJsonFactory(jsonFactory)
.setServiceAccountId(SERVICE_ACCOUNT_EMAIL)
.setServiceAccountScopes(SCOPE)
.setServiceAccountUser(USER_EMAIL)
.setServiceAccountPrivateKeyFromP12File(
new java.io.File(SERVICE_ACCOUNT_PKCS12_FILE_PATH))
.build();
For additional examples and information, check out https://developers.google.com/+/domains/authentication/delegation.
Also, if you do wish to compile a list of Google+ IDs, you need only make a people.get API call using the email address for the authenticated user, and the Google+ ID will be included in the Person response. (https://developers.google.com/+/domains/api/people/get)