How to access to userDefined or ExtendedProperties data of a User in Directory API - google-contacts-api

Since the Google Apps Profiles API has been officially deprecated. It has been replaced by the Directory API.
The fields (Organizations, Phones numbers, ...) of a ContactEntry (Apps Profiles API) exists in the User (Directory API).
But I cannot find the UserDefinedFields and ExtendedProperties fields in the User of Directory API ?
How can I have access to these kinds of data ?

The Directory API exposes custom Schemas. Your app can create a Schema object and define the fields supported by that schema. Then you can include json to set fields in that schema. However, the fields are associated with that schema. The intent appears to be to expose those fields to custom apps, not as part of the data shown for a user in the Contacts Directory. If you had code which set UserDefinedFields on a user's profile object and were visible in the Contacts directory those fields are not visible to the Directory API. It also appears that you can't use Directory API Schemas to add user defined fields to a User that will show up on their profile view in Contacts Directory.

Related

How to store organization specific configuration values in properties?

I'm developing a Gmail Add On with Google Apps Script, which is intended to be used only by enterprise accounts (Google Workspace Accounts).
One of the requirements of the app is that when the Admin installs the app for all its users, they have to configure some organization wide configuration values (a license key for example).
I tried with the following code:
const userProperties = PropertiesService.getUserProperties();
userProperties.setProperty('licenseKey', '[TOKEN]');
But when I do this, the data is only accessible for the current user (and therefore I would need every user to know this key in order to save it on the configuration variables). I'm looking for an option in that a user saves this setting variable and then everyone on the domain can read the saved value.

Google Drive API get AppProperties with API Key

Question:
Is it possible to access the appProperties field in a Google Drive document via an unauthenticated user (i.e., via API Key or other method rather than Oauth)?
Background:
I have an app that works as a live document editor. It authenticates users via OAuth and allows them to save those documents to their google drive, and later re-open them in my app (google file ids are saved in my database and will load the document text into my app). Create()-ing and Get()-ing these files works fine as long as the user is signed in, and I have the "appProperties" field storing a couple of additional key metadata items.
As a next step, I would like to allow users to mark a document as "public view", and provide read-only access to their file, even for non-logged-in users. In my head, the flow would work as follows:
User_A authenticates with OAuth and creates a document, saved to their google drive.
User_A presses a button in my app, which sets the google document to a public sharing mode?
App generates a "viewer" link that User_A can share with his friends.
User_B does not have a Google account, but visits the "viewer link", and my app looks up the appropriate google document (using API key? since User_B is not logged in)
Document is loaded into my app for viewing.
This seems to mostly work; I can read the file metadata just fine using the API key, and even get the file contents. Side Note: Why do we need the API Key at all, given the quote on the google drive api page: "Note: Authorization optional."
However, the "appProperties" field always returns empty when using the API key!
Edit: After further searching I am just more confused. The closest answer I could find was from this related question here on stackoverflow:
It's very simple. appPropperties is a private field and is available only to the application that added it.
Based on this, it seems Google Drive is treating requests from my app API Key and requests from OAuth users on my app as two separate apps?
Further, I would eventually like to allow users to collaborate on a single document, owned by one user. So instead of just providing a read-only "view" link, they could generate an "editor invitation" link that would allow an authenticated user (User_B gets a google account now) to be added as an authorized collaborator (but not simultaneous editing) on the original (User_A's) document. Is that even possible?
Note I am using the Node.js google api.
This might be a bug:
appProperties are app-specific properties attached to a file. Any call from this app should be able to access them. Therefore, I think calls from this app using an API key should be able to retrieve these properties.
I could reproduce this behaviour: appProperties are populated when using OAuth, but not when using an API key, even though both are created from the same GCP project.
I filed a bug:
After researching this issue, I think this might be a bug. Therefore, I decided to file a bug on Issue Tracker:
appProperties are not populated when accessing a public File using an API key
To anyone affected by this, I'd suggest to click the top-left star in order to keep track of this and to help prioritizing it.
Reference:
Add custom file properties

Where is the JSON credentials file for Ansible provision of Google Compute Engine?

I follow this guide http://docs.ansible.com/ansible/gce_module.html
And it indicates that credentials_file in JSON format could be used instead of the deprecated pem_file. Where can I get this credentials file?
Go to the Developers Console Credentials page.
From the project drop-down, select your project.
On the Credentials page, select the Create credentials drop-down, then select Service account key.
From the Service account drop-down, select an existing serivce account or create a new one.
For Key type, select the JSON key option, then select Create. The file automatically downloads to your computer.
Put the *.json file you just downloaded in a directory of your choosing. This directory must be private (you can't let anyone get access to this), but accessible to your web server code.
Set the environment variable to the path of the JSON file downloaded.
https://developers.google.com/identity/protocols/application-default-credentials#howtheywork

Is there any way to download folder and files for specific user using box api?

I have a user which has co-admin privileages. i HAVE ACCESS AND AUTH TOKEN CORRESPONDING TO CO-ADMIN. In my code I first fetch all the users present under given enterprise account and then for some specific users i want to download all the folders and files. Is there any way to do so?. I know that box api does have GetFolder(). but this api does not take any arguments such as username . It requires a folder id and It will always return all the folders and files under that id.
It sounds like you want to use the On-Behalf-Of header. Once you've authenticated an admin account, you can use this header to make any API call on behalf any of the users in the admin's enterprise.

Finding external shares using Google Drive

I currently have an application that will search document acls and report back on any external sharing. Since the deprecation of the document list api I would like to covert this application to Google Drive but since the user email address is no longer present in the Permission object returned from Drive is there any way to detect these shares?
Thanks.
Match the username you get from the Owner field to the users in your directory using the profile api https://developers.google.com/google-apps/profiles/. If the user is not in the directory, the user is external.
I suggest you to use 'domain' field in permission to define if your document is shared with an external user or not. You have to campare this field with the domain that you own.
Thanks,