How can I add contact by Account ID with Google People API? - google-people-api

I have a bunch of people I would like to add as Google Contact.
For each of them, I have the google account ID.
I would like to use Google People API, but so far I've failed.
Here's what I've tried :
-provide Google Id as ResourceName (pre-formating people/id). I got a 400 error with message : "Request person should not have a resource name."
-provide Google Id as a metadata, formating it properly in sources[0].id. I also got a 400 error with message : "Request contains an invalid argument."
I'm kinda stuck here, does anyone have an idea ? Thanks a lot !

I also wanted to add contacts using the people API, based on the directory profile. I got this working by using the following body:
body = {
"names": [{"familyName": "Doe"}],
"emailAddresses": [
{"metadata": {"primary": True}, "value": "doe#domain.com"}
],
}
The contact was added and when I compared the contact with another contact that I created manually based on the directory, the properties were the same.
My conclusion is that, by adding the G Suite primary address, Google will figure it out on its own.

Related

#TopicNotOwnedByProject error while creating google classroom registration for topic

I have two google cloud console projects. First one is for authentication purposes only and the second one is for work with classrom, it has topic, subscription, and classroom courses. I added user to both projects, on the second porject he is an owner, and for some reason i started to get errors while creating course registration to topic after authenticating on first project.
Full error is:
"error": {
"code": 403,
"message": "#TopicNotOwnedByProject The specified Cloud Pub/Sub topic does not belong to your Developer Console project.",
"status": "PERMISSION_DENIED"
}
When i do sign in in first project i use owner account for second project. So in request i pass token which got after signing in first project.
This errors started to appear about 3 weeks ago, did google change something or i am missing something?

Instagram Graph API - Use Business Discovery and Insights edge combined

I am able to fetch the list of media objects associated with an external user using the following URL
GET (my IG user id)?fields=business_discovery.username(therock){media{caption,children,comments_count,like_count,id,media_type,media_url,owner,timestamp,username}}
How do I fetch the Insights of an external user using the above method. I do know to fetch the insights of my own account using the following URL
GET (my IG user id)/insights?metric=impressions&period=week
When I try to fetch the insights using the URL below
GET (my IG user id)?fields=business_discovery.username(therock){insights}}
the following error is thrown
{
"error": {
"message": "Syntax error \"Expected end of string instead of \"}\".\" at character 46: business_discovery.username(therock){insights}}",
"type": "OAuthException",
"code": 2500,
"fbtrace_id": "FeWhDF4hOJY"
}
}
Is it possible to fetch the insights of an external account?
To retrieve insights from a FB page you have to provide credentials from one of the page admins. If you have them, you don't need to use the business_discovery endpoint. If you don't have them, you cannot retrieve insights.
GET (my IG user id)?fields=business_discovery.username(therock){insights}}
Looks like you simply left an extra } there at the end - remove the superfluous one, then the error should be gone.
(With {media{...}} you had two levels of nesting, but now you have only one.)

Configuring single federated login to AWS using Google Apps using Users Patch API - Found array where value was expected

Last week I followed the steps in the "How to configure single federated login to AWS using Google Apps" tutorial, and everything went as expected. Yesterday (2016-12-12) I returned to the panel to use the "Users: patch" Google API to set up new roles for my users based on the Schema SSO created according to the tutorial, but I was not able to execute the request as I had done the previous week.
The following error message is displayed in the "Try this API" panel:
"Found array where value was expected"
Here is an example of the request body as defined in the tutorial (Note - in this example I am using placeholders for the values ​​of the value and customType fields):
{
"customSchemas": {
"SSO": {
"role": [
{
"value": "<my aws role ARN>,<my aws provider ARN>",
"customType": "Developer"
}
]
}
}
}
From what I understand the message is related to the role field.
I would like to understand what changed from the previous week to yesterday and how should I configure the JSON for the "Users: patch" API according to the SSO Schema created the previous week?
I was able to get to the "Freeform" editor and make the changes using this url instead of the one in the AWS documentation. I was having problems getting Postman to authenticate with google, which made this easier.
I had to make some slight changes for this to work.
I followed the steps from this article (same article OP used)
I used this URL to get to the freeform editor (same link as above answer)
In step 4 of the article, which is the step before the question posted by OP above, I used 'SAML' as the schemaName rather than 'SSO'
I then used 'SAML' as the customSchema name in the question above, rather than 'SSO' and repeated the process with different email addresses for other users
Followed the rest of the article and FINALLY my SSO to AWS from g-suite works.

Like Facebook post of user, Who is not in my friend list or you can say liking a public post

I have two Facebook test users A and B. Both users are using my Facebook app. As app in development mode, I give all the permissions to app for both the users and created the access token for both the users.
Now I can get feed of both the users A and B. So I found a feed of user B used post id is 238863083139817. But when I tried to like the post of B from A using given bellow graph API.
POST/v2.6/1542696762701116_238863083139817/likes
I got the error message give bellow.
{
"error": {
"message": "(#100) Error finding the requested story",
"type": "OAuthException",
"code": 100,
"fbtrace_id": "DH4NvDpj3aN"
}
}
Here 1542696762701116 is my id.
Anybody know how can I like the post of user who is not in my friend list.
The same code will work if user A and B will be friends.
At first sight, it seems to be a problem with the permissions of the application. Maybe could you add some to check if the problem remains.
For instance, I saw that post:
"(#100) Error finding the requested story" encountered when POSTing like on a post
It talks about the permission: read_stream that can help to solve your problem.
Could you try and give your feedback?

How do I find the immutable id of my Google Apps account?

Many of the Directory API calls require a customer parameter referred to as the "Immutable id of the Google Apps account. (string)".
e.g. GET https://www.googleapis.com/admin/directory/v1/customer/customer/domains
I have no idea how to find/generate this for my Google Apps account. I am an admin.
Can someone point me in the right direction please?
I was able to find the customerId as follows
Go to admin.google.com
Security -> Set up single sign-on (SSO)
You will see URLs like this:
https://accounts.google.com/o/saml2/idp?idpid=Cxxxxxxxx
That Cxxxxxxxx is your customerId
Had the same question, so I had to contact their chat support.
The official answer was:
There are no any web interface to look up this information - as I would expect for example in "organisation admin panel". The only way to get this information is from the code.
You have to write extra code to request information about any existing user:
(Link to API Docs - GET: https://www.googleapis.com/admin/directory/v1/users)
And in the response, you can find field customerId which is the same for each user in the company across all domains.
That is the only way to find your organisation customerId...
Not user-friendly, so I will submit "Feature Request" right now to Google.
The easiest way I found was to use the APIs Explorer at the bottom of the documentation for the Customers: get method on the Directory API (Admin SDK). Enter 'my_customer' for the customerKey on the form and hit the 'Authorize and Execute' button.
The response will include the CustomerId (e.g. Cxxxxxxxx) as the "id". The entire response will look something like this:
{
"kind": "admin#directory#customer",
"id": string,
"etag": etag,
"customerDomain": string,
"alternateEmail": string,
"postalAddress": {
"organizationName": string,
"countryCode": string,
},
"language": string,
"customerCreationTime": datetime
}
If you are part of an organization, you can find it here as Organization ID: https://play.google.com/work/adminsettings?pli=1
It works for G Suite accounts and Gmail accounts that are associated with an organization, but not for individual Gmail accounts.
I found something simpler: gcloud organizations list. It will give you DISPLAY_NAME, ID and DIRECTORY_CUSTOMER_ID (this is what your are looking for) for all you organizations.