I built a platform in PHP that enables users to create their own websites. To connect the site owners to Google services (specifically Google Analytics), I created a Google application for my site users to connect to their account. This is done through Google's API V3/OAuth2.
The flow is:
- User logs in to Google Analytics with their Google account.
- The platform automatically adds a Google Analytics snippet to the website
- The platform allows offline access to Google Analytics to view site statistics and displays it in a statistics screen.
The problem:
There is a limit of 25 for the number of refresh token I can have per application. When the 26th user logs in (and receives a new refresh token) the first refresh token becomes inactive.
The Error message:
error: 1401351409|4794
[Error refreshing the OAuth2 token, message: '{ "error" : "invalid_grant" }']
I am getting this after making the refresh token request to the API.
Is there any way to overcome this limit? Is there any other way I can get the desired outcome?