catalystbyzohozohocatalystcatalystcloudscale

Getting OAUTH_SCOPE_MISMATCH error when testing Stratus from my Catalyst Function


I got the early access for Stratus feature for my account and I have installed the Beta SDK in my catalyst Node Advanced I/O function and initialized the Stratus Beta SDK using the below code snippet as mentioned in the official help documentation here

const bucketInstance = await stratusInstance.bucket("mybucket");
const bucketDetails = await bucketInstance.getDetails();

But when I try to run the function in my local machine using the Catalyst CLI command catalyst serve, I am getting the below error

Error in getting bucket details: {statusCode: 401, code: 'OAUTH_SCOPE_MISMATCH', message: 'invalid oauth scope to access this URL'}


Solution

  • The error OAUTH_SCOPE_MISMATCH indicates that the access token used for accessing Stratus from your function SDK doesn't have correct scopes related to Catalyst Stratus. Since you are testing the function in your local environment using Catalyst CLI, you would have received the necessary scopes during login which didn't include Stratus related scopes.

    To resolve this issue, you can try relogging into your Catalyst CLI after updating your CLI using the below command

    npm install -g zcatalyst-cli@beta
    

    Once you have updated the CLI, you can relogin to your catalyst account using the below command where you should see the Stratus related scopes in the login URL.

    catalyst login --force
    

    Once logged in, you should be able to test your function successfully