Currently i'm trying to retrieve all of a users contact information as well as retrieve their unique User ID.
Our app needs to utilise a users google contacts and the user will sign in using google. Thus we require some way of identifying each unique user (most likely a unique user id provided by google)
Is this possible only using the google contacts API.
The initial call I make to retrieve an access token is:
"https://accounts.google.com/o/oauth2/auth?client_id=51672309258-94cnvnrkrverd72neakom9d3siscda5o.apps.googleusercontent.com&redirect_uri=http://localhost/lunch/oauth.php&scope=https://www.google.com/m8/feeds/&response_type=code"
However I do not believe the access token returned from this call has any information for user ID and, also, does not provide the permissions to retrieve User ID from the Google+ Api.
Is there anyway that one can obtain a unique user ID from the google contacts API? There are examples of obtaining a user id of the users contacts but I need to obtain the actual users ID (i.e. the user whose contacts I am obtaining)?
Does this require another scope or can this also be accomplished by using the contacts API?
You can identify a user by his/her email address, which is unique AFAIK. When you issue requests to google contacts api you get a field in the xml which is called Id, that is the user's email address.
For example you could ask for all contacts and you would get an xml like this .The Id field is what you want, and depending on the programming language, lib , etc you are using you can get it with your existing permissions. For example in C# and gdata you would do something like this(googleCredentials is supposed to be your object):
var cr = new ContactsRequest(settings);
var feed = cr.GetGroups();
googleCredentials.Email = feed.AtomFeed.Id.Uri.Content;
Note: The special userEmail value default can be used to refer to the
authenticated user.
from the documentation documentation. You may try the keyword default as userEmail.
Related
I've been searching the docs but I can't find anything.
The goal is to retrieve different stats from our files. Actually, we can retrieve almost everything we need, except for the document openings and document openings per user.
So here is the question: How can I retrieve document views of a drive document (a G Sheet to be more precise) ? Can I segment it by user ?
Thank you
I understand that your goals are the following one:
You want to retrieve document views
Of a particular document (and you know it's id)
Associated to a specific user
Please correct me if I get it wrong. If those are your goals, then you can use the Admin SDK as pointed out by Rubén in the comments. Now I am going to detail how you can make such a request easily.
You could use the method activities.list() to get a list with what you want. You only have to populate these four parameters:
Parameter
Value
Description
userKey
The user's email
Determine the user
applicationName
drive
Identifies the Google service
eventName
view
Designate the type of activity
filters
doc_id=={MY DOCUMENT ID HERE}
Filters by the document
That configuration will provide you with your desired data. Leave a comment below if you need help creating that request in your own environment.
Currently I am developing a Chrome-GMAIL extension which requires me to get the logged in user's first and last names. For experimentation, I have used the following goggle API (userinfo) and have successfully obtained the names I wanted:
https://www.googleapis.com/auth/userinfo.profile
However, using the userinfo APIs will cause a change in the OAuth2 scopes in my manifest. This change will in turn cause a permission-prompt to my existing users (if a domain wide delegation is not setup in place). Point being the idea of having more prompts in front of my user, or additional oauth scope is not really something I desire.
Currently our extensions use the following OAuth scopes and API :
Chrome's Identity API
Chrome's Storage API
GMAIL.modify
GMAIL.send
My question is, is it possible to get the first and last names using an API that is defined/allowed/provided for by any of the above scopes/permissions I listed? or is userinfo the only way to go?
Thank you very much.
Profile data like first name and last name is private data. You are corect that some Google apis give you access to some data that would normally require an extra scope. For email normally you would need to to request the email scope to get this back however the Gmail api does have an endpoint getprofile which will return the current users email address without you requesting the email scope.
However i am not aware of any apis that will give you access to the users first and last name without you requesting the profile or user.profile scope.
If you do decide to add the scope, I do recommend going though the people api rather then the userinfo endpoint as the data returned by the user info endpoint is not guaranteed to always return the name.
How to check a Google app account is present in a domain or not using Google app script (with email id)?
I would like to reset the password of accounts in my domain. Before that i need to check if those accounts exists in my domain or not. So with a given email id, i need to check id this particular email id is present in my domain or not and it should be primary email address.
Please let me know if this is feasible or not.
Thanks
I think you can try to retrieve all users in your domain by following this documentation.
To retrieve all users in the same domain, use the following GET request and include the authorization described in Authorize requests. For readability, this example uses line returns:
GET https://www.googleapis.com/admin/directory/v1/users ?domain=primary domain name&pageToken=token for next results page
&maxResults=max number of results per page
&orderBy=email, givenName, or familyName
&sortOrder=ascending or descending
&query=email, givenName, or familyName:the query's value*
Also check this SO question, if it can help you.
We're using multiple Facebook apps for our product, in V1.0 we used to get the same user id for all apps. We save accounts collection in our db in which we save Facebook id in and creating new accounts for users in which we don't have their FB id already.
Last week we've created a new app, when we started to use it we found out that we're getting a different id for existing users and we're creating a new account for them in our db. (This happened because the new app was created on v2.0 as explained here - https://developers.facebook.com/docs/apps/upgrading#upgrading_v2_0_user_ids)
I read that we can use business manager in order to define all apps and get all the user id for all apps under the same business (https://developers.facebook.com/docs/apps/for-business), but I couldn't find how can I connect these ids to the original id.
I saw a hack that once I have app_scoped_id, I can make a another FB api call to get the original id (Get Facebook User ID from app-scoped User ID) but this means I keep managing the FB ids on our db, is this a good approach? or should I move on to manage the app scope ids? how can I get them for my V1.0 apps before this transition takes place? can I migrate my data in db (when having FB global ids only)? or do I must have a user access token in order to get this info?
Thanks!
Ilana
I have read from previous posts [1, 2, 3] that the email address is not displayed for Google Drive Permissions API due to privacy reasons. But I am trying to look for a way to display user permissions where there are 2 different users with the same name.
With the Google Drive sharing UI, you can differentiate two different users with the same name as it also displays their email next to their name (I don't see why this is not possible in the API if the Google Drive UI can get it).
I would prefer not having to rely on the now deprecated DocList API to get the emails from the ACLs.
Unfortunately, using the documents list API is your only option for now to get the email addresses, sorry.
With v3 API yu can specify the fields parameter of your request.
For Get request : request.Fields = "kind,id,type,emailAddress,domain,role,allowFileDiscovery,displayName,photoLink,expirationTime,teamDrivePermissionDetails,deleted"
For List request : request.Fields = "permissions(kind,id,type,emailAddress,domain,role,allowFileDiscovery,displayName,photoLink,expirationTime,teamDrivePermissionDetails,deleted)"
About about = service.about().get().execute();
User user = about.getUser();
System.out.println("user" + user.toString());
You can print out the user information (JSON string).
It contains the emailAddress.
You can parse the JSON string for the emailAddress.
list does not return email, but get does
permission = service.permissions.get(fileId,permissionId)
System.out.println("email" + permission.emailAddress);