TikTok accounts API: Access token is always expired

249 views Asked by At

I'm trying to make a simple TikTok API app in Python, using their accounts API to pull some data. I've followed the authorisation steps to the letter, got an access token & a refresh token, but now plugging the access token into their endpoints just gives the response

{"code":40105,"message":"Access token is incorrect or has been revoked.","request_id":"20240108171626B0CBB6EB6DEE3269C0F3"}

I've been following the API documentation here, here and here, and it's given me back an access token & refresh token; I can happily plug this refresh token into their refresh endpoint and it tells me all's good to go. But when I run this code:

def get_follower_count():

    url = "https://business-api.tiktok.com/open_api/v1.3/business/get/" + f"""?business_id={open_id}&fields=["display_name","followers_count"]"""
    headers = {
        "Access-Token": f"Bearer {access_token}"
        }
    return requests.get(url, headers=headers)

I get the above message back.

I retrieved the access token today, so there's no reason for it to have expired.

Has anyone else encountered this problem? Is TikTok's API just broken?

0

There are 0 answers