Reputation: 133
We currently have Google Apps for Education in use and have enabled Google Plus. I have looked at many of the API's google offers https://developers.google.com/oauthplayground/ and have had no luck in finding an answer.
I'd like to be able to query the user in google apps and find out their Google Plus ID.
Google+ has its own API and I know is in beta for education so it may simply be that they haven't added to this list: https://developers.google.com/google-apps/ under application API's.
Is it possible with a combination of calls maybe to get the Google Plus user ID from our users email?
Thanks in advance.
Upvotes: 1
Views: 4081
Reputation: 403
Follow these simple steps to find your Google Plus User ID:
1) Login to your Google+ account.
2) From the side menu click on the Profile icon
3) In the address bar you will see your complete Google+ URL. It will look something like this:
https://plus.google.com/100009709084787102522/posts
4) Your Google Plus User ID is the long series of numbers. in this instance my Google+ ID is the following:
100009709084787102522
Reference : http://www.jumpmobi.com/miscellaneous/what-is-my-google-google-plus-user-id/
Upvotes: 0
Reputation: 133
I couldn't get the answer posted on Dec 4 2012 to work, perhaps the google+ api changed since then, or I just missed something. However, I did get the profile info (including id that the original poster wanted) using google's quickstart example:
https://developers.google.com/+/quickstart/javascript
Upvotes: 0
Reputation: 8681
It depends on what you're trying to do, as far as I know, you can't just lookup someone's Google+ id in your system given their email.
However, if the user signs in, you can get the user id as described on the History client side starter Google+ history client-side flow. Instead of writing moments, you read the profile and then can retrieve the id for their Google+ account. You will need a client id from the Google APIs console with the Google+ service enabled, same as the client-side flow. Once you have this id, you can create the HTML page that will get the Google+ id using the JavaScript client.
The following code shows how you can do this:
<html>
<script src="https://apis.google.com/js/client.js"></script>
<script src="https://apis.google.com/js/plusone.js"></script>
<script type="text/javascript">
function onSignInCallback(authResult){
// Set the access token on the JavaScript API Client
gapi.auth.setToken(authResult);
var args = {
'path': '/plus/v1moments/people/me',
'method': 'GET',
'callback': function(response) {
var profile = response;
console.log(profile);
alert('id is ' + profile.id);
}
};
gapi.client.request(args);
}
</script>
<body>
<!-- Render the sign-in button -->
<g:plus action="connect"
clientid="YOUR CLIENT ID"
scope="https://www.googleapis.com/auth/plus.me"
callback="onSignInCallback"></g:plus>
</body>
</html>
When you run the above code, it will popup the signed in user's ID as an alert. If you're trying to do this for a non-Google (e.g. GMail) account, log in with your domain credentials to get that Google+ account id.
Here is a demo of this code.
Upvotes: 1