php - Google Analytics OAuth2 refresh tokens limit -
i built platform in php enables users create own websites. connect site owners google services (specifically google analytics), created google application site users connect account. done through google's api v3/oauth2.
the flow is:
user logs in google analytics google account. the platform automatically adds google analytics snippet website the platform allows offline access google analytics view site statistics , displays in statistics screen.the problem:
there limit of 25 number of refresh token can have per application. when 26th user logs in (and receives new refresh token) first refresh token becomes inactive.
the error message:
error: 1401351409|4794 [error refreshing oauth2 token, message: '{ "error" : "invalid_grant" }']
i getting after making refresh token request api.
is there way overcome limit? there other way can desired outcome?
from understand google's oauth2 documentation, issue experiencing:
google oauth2:
there 25-token limit per google user account. if user business relationship has 25 valid tokens, next authentication request succeeds, quietly invalidates oldest outstanding token without user-visible warning.
i pretty sure refresh tokens unique client id/user id/application scope combination. when issued refresh token, should storing refresh token particular user in database, rather generating new ones. when user's original access token expires, application should pulling user's corresponding refresh token database , generate new access token/refresh token next usage.
with right flow, should not come close reaching refresh token limit.
hope helps!
php google-analytics oauth-2.0 google-analytics-api
No comments:
Post a Comment