How manage access token and refresh token when using go highlevel's 2.0 api
location_id = models.CharField(max_length=300)
access_token = models.TextField(max_length=500)
refresh_token = models.TextField(max_length=500)
expires_in = models.PositiveIntegerField()
created_at = models.DateTimeField()
last_updated_at = models.DateTimeField()
This approach avoids the edge case of token expiration just before the request. Dont worry about ratelimit. Works for every situations.
We're creating a custom function in utils.py. This function accepts method, location id, url and params
We're going to use this function for every request.
This function checks token validity before request if token expired we're updating the token. And alse checks for ratelimit using go highlevel response's headers.
If you are using the custom request function inside Django's request response cycle, It would be good to remove the rate limit management part to avoid Gunicorn timeout.
Checkout custom_request() in auth_app/utils.py