The error occurs because the access token lacks the required scope. Ensure you include the correct scope when generating the token and refresh it properly. Here is the code snippet you can refer to:

In the above code, we are using the following key points: