Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Google Analytics wrong result #131

Closed
anddimario opened this issue Jan 22, 2014 · 8 comments
Closed

Google Analytics wrong result #131

anddimario opened this issue Jan 22, 2014 · 8 comments
Assignees
Labels
🚨 This issue needs some love. triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@anddimario
Copy link

Hi, only for some analytics request we have this error:

<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">
<html>
<head><title>Google Accounts</title><meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\"><meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\" /><meta name=\"viewport\" content=\"width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=0\" /><link rel='stylesheet' type='text/css' href='https://ssl.gstatic.com/accounts/o/1893590695-error_page_css_ltr.css'>\n<script type=\"text/javascript\" src=\"https://ssl.gstatic.com/accounts/o/4240385162-common_lib.js\"></script>\n<style>@media screen and (max-width:500px) {#robot {background: none; min-height: 0; min-width: 0; padding: 0;}#stack_trace {display: none;}}\n#oauth2_request_info_header {background-image: url(\"https://ssl.gstatic.com/accounts/o/blank.gif\");}</style></head>
<body ><div id=\"robot\"></div><a href=\"//www.google.com/\" id=\"googlelogo\"><img src=\"//www.google.com/images/logo_sm.gif\" alt=\"Google\"></a><p class=\"large\"><b>403.</b> <ins>That's an error.</ins></p><p class=\"large\">You are not authorized to perform this request.  <ins>That's all we know.</ins></p></body>
</html>

It's displayed not as error, in the callback, but as normal result.

Have someone some suggestions about this problem?

Thanks for your time.
Best regards.

@rakyll
Copy link
Contributor

rakyll commented Jan 22, 2014

What's your request? Could you share a snippet?

@anddimario
Copy link
Author

Hi, yes, sorry, here: https://gist.github.com/anddimario/8559849

Thanks for your time.
Best regards.

@rakyll
Copy link
Contributor

rakyll commented Jan 24, 2014

I'm not able to reproduce, would you like to share your request_object? Which googleapis version you're depending on?

@anddimario
Copy link
Author

Hi, i've edited the gist with the complete object ( https://gist.github.com/anddimario/8559849 ). I'm using the npm version 0.4.7. I'm doing other tests, it seems that the problem is the requests number (but it's not a normal rate limit error) and not the single metrics, i've tryed to refresh the tokens for each request without results.

Thanks for your time.
Best regards.

@rakyll
Copy link
Contributor

rakyll commented Jan 24, 2014

I'm looking at your code, and if a refresh token is invalid, there are multiple token refreshing requests are made concurrently which is racy and may malform the request body. The best approach is to refresh the token manually if oauth2client.credentials. expires_in is likely to happen soon.

Qps related errors will returns a rate limit error which has a valid JSON body.

On the other hand, IMHO, client library is doing a bad job while handling token refreshes and I've initiated ideas several times in the past to fix it. But, the expectations of developers in terms of the default behavior on token expires were very diverse and wrapping a solution into OAuth2Client was not meeting everyone's needs.

@anddimario
Copy link
Author

Hi, understood, really thanks, i'll do some test based on your suggestions. Only one last thing, is the expires_in available from the module, or should i make a direct http request to google api to get this? On oauth2client i've only: access_token, refresh_token and token_type.

Thanks for your time.
Best regards.

@ryanseys
Copy link
Contributor

Just released 1.0.3 which likely addresses this issue. The access token will be refreshed prior to initial request if has expired or is missing and you have a refresh token set. If the request fails due to a missing, invalid, or revoked access token, we will no longer attempt to refresh and re-attempt the request.

https://github.com/google/google-api-nodejs-client/releases/tag/1.0.3

@ryanseys
Copy link
Contributor

ryanseys commented Aug 8, 2014

We have tried to make it as straightforward and well documented as possible so as to avoid making incorrectly formatted requests, especially around refreshing access tokens. Closing this as I believe we have eliminated this issue, especially around checking expires_in and using it to automatically refresh the access token before making requests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🚨 This issue needs some love. triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

4 participants