recently I've started using http://code.google.com/p/google-api-php-client/ (Google OAuth2) for my web app.
However I draw a blank because I cannot read the timezone for my user.
I tried enter it somehow on my Google account page but I didn't found any such field.
Does anybody know if Google really offer such information and if so how can I set it to my account for example?
The closest thing available to you is the timezone available on your Google calendar. Check the 'General' tab on your calendar settings page: https://www.google.com/calendar
Now, you can request access to the user's calendar while you're authenticating them to your service. Use the scope "https://www.googleapis.com/auth/calendar" (docs)
When you're authenticated, you can request the calendar you're interested in. I guess the user's primary calendar is your best bet.
Finally, each calendar has settings with a timeZone property.
Here's sample code for the Google API PHP client.
As of March 21, 2013 Google is not providing this information in their response to the userinfo.profile endpoint -- even though they claim that they do.
This documentation claims that timezone is available:
https://developers.google.com/accounts/docs/OAuth2Login?hl=en#userinfocall
However, the current implementation only returns the following data:
id
email
verified_email
name
given_name
family_name
link (to G+ profile, if available)
gender
birthday
locale
hd (appears to be the Google Apps domain, if relevant)
Note that "birthday" and "hd" are not listed in the current documentation on the page listed above. I am verifying these fields from real-world responses I'm receiving from the endpoint.
The best approach for getting timezone at the moment is probably to use JavaScript (to retrieve the timezone from the user's browser). This StackOverflow answer explains how to do so:
Getting the client's timezone in JavaScript
Unfortunately, this would have to occur as a secondary action, meaning you'd have to add this data to your database separately from the data retrieved from the endpoint. One trick to consider is capturing the timezone offset on the page where you initiate the endpoint request, and then appending the timezone offset value to the "state" value in your OAuth request. This value will then be returned on the callback, and you could extract and add it to the other profile information that was returned during the same procedure in which you write to your database.
Related
Im using the following endpoint - https://dev.twitter.com/docs/api/1.1/post/friendships/create - to follow Twitter accounts. However it does not work when attempting to follow age restricted accounts, for example https://twitter.com/StellaArtoisUK as you have to specify your age when attempting to follow them in the web browser.
Am I able to pass the parameter of my age with the call to the endpoint or is this functionality not currently supported by API 1.1?
The API documentation makes no mention of such a parameter. However, according to the Age Screening page on Twitter.com, so long as the user has entered their age through the web browser at some point, they'll never be prompted again. So, if you can catch this exception in your code, you could show your user a message explaining that they need to visit this page from a web browser before viewing it in your application.
I'm currently building a test and trying to get a google+ user location. I'm testing on myself and have set my position to public.
I was originally planning to use Google Latitude, however, since Google is deprecating this API in a few days, my only option is to use the Google+ API.
The parameter currentLocation was added a few months ago
I'm therefore trying to get it. But could not manage to do it.
I've tested on my own server using the PHP API and then the JS API with Oauth2.0, but this damn parameter is never sent back. I can get any other parameter but definitely not that one.
Then I've tested in the google+ explorer, but same thing here, nothing came out
Does anyone have already encounter a similar issue ?
I have a few idea where it could come from :
Does Oauth2.0 does not let me access this information (I've tried
any possible data-scope)
Is there just a bug on this functionality ?
Is it restricted to verified users ?
Or maybe it's just not possible ?
Thanks !
Access to location data is restricted to users who have granted you access to their location data at the time that the OAuth token was generated.
You have to specifically request access to location data in the scope parameter.
What I think is that r.placesLived would only give his location but the location of the user nor the location of the exact machine. It could be remembered that you need to have the address. However, it needs to look for another token for verifying a user's exact location. Going into it might only need more of a tracker and not only a location.
This is an old one but still valid question. Even field "currentLocation" is listed as valid reponse People object field, there´s no way to access field´s data.
Was reported as issue in G+ repository but there is no answer so far.
If you are still trying to get user´s current location try the following snippet, not sure if this is the best option but it works :):
Note: "r" holds the client.request() response data (API call)
r.placesLived.forEach(function(l) {
if (l.primary)
console.log(l.value);
});
Hope this helps.
Cheers.
Problem : I am facing difficulties in getting user's birthday from api calls and I am new to OAuth.
Steps followed : (Have followed all steps required for implementing login with google+)
1. Created an app.
2. Obtained app_id and secret_key.
3. Did not make use of SDK, implemented the process without SDK in php.
4. Obtained "CODE" by calling accounts[dot]google[dot]com/o/oauth2/auth?
5. Using the code from the URL parameters requested for access token by HTTPS POST method to https://accounts.google.com/o/oauth2/token, using CURL
6. When accessing the login page, user is asked for permissions to access the information such as email, profile, DOB etc., but I am not able to find a way to get that date of birth
7. I have tried access www[dot]googleapis[dot]com/plus/v1/people/User_ID?key={THE_API_KEY} . Still no luck
Please guide or suggest me on how to get the DOB. Also let me know if there is any other information I missed to share.
Thanks in advance.
Cheers!
Farhan
Well Well Ofcourse.. It has to be a security thing from google.
I got to know after I did a part of unit testing with different scenarios and missed out on a simple thing that google only responds with the b'day information if the user has allowed to in his profile settings.
all if the birth year is hidden, it will throw 0000 as year in the response of the HTTPS Post method.
If I am wrong in any of the information provided, Please do correct me.
Cheers!
Farhan.
I would like to get the user's country info as specified in the documentation [1]. I tried using the Google API explorer and the samples, and still cant get the country info. I even tried updated the test account's profile info.
[1] https://developers.google.com/accounts/docs/OAuth2Login
[2] https://developers.google.com/apis-explorer/#p/oauth2/v2/oauth2.userinfo.get?_h=15&
The field editor in the Google API does not list parameter for country either. Is there some undocumented way that anyone knows about. Assuming that the user would provide complete access for their profile to the client app.
I am afraid that the documentation is inconsistent.
In the description of the userinfo.profile scope we do list "country" as part of the basic profile information being authorized by the user. However, and as described later in the documentation, locale information is provided instead.
The documentation will be updated shortly in order to avoid further confusion.
When i get the response from google contacts API using Oauth2.0, it Returns the response something like as follows
"The site 251543634636.apps.googleusercontent.com is requesting access to your Google Account for the product(s) listed below. ...etc"
In which, how to display my web application name in place of client_id like 251543634636.apps.googleusercontent.com
Any help would be greatly appreciated.
All you need to do is register your application, and then a more friendly description can show up for the user. Instructions on how to do this are documented here:
http://code.google.com/apis/accounts/docs/RegistrationForWebAppsAuto.html
Note the section that says:
Domain description: This optional value should briefly describe the
domain you're registering. In the future, this description may be
displayed on the Google Access Consent page to provide additional
information for your users. You always have the option of changing
this description or leaving it blank.
Good luck!