CRM API V4 Oauth Issue

CRM API V4 Oauth Issue

writing a CRM custom function to get all user types and user type IDs for an existing CRM portal in my org according to https://www.zoho.com/crm/developer/docs/api/v4/get-user-types.html.
I have a ZOHO One subscription and I am the only user (Administrator).
  1. have checked all community posts for a similar issue (none found)
  2. have checked permissions within the CRM and can find no enabled settings that would prevent this function from executing successfully
  3. The token is successfully returned with appropriate scopes
    1. {"access_token":"1000.XXXX","scope":"ZohoCRM.settings.ALL ZohoCRM.modules.ALL ZohoCRM.settings.clientportal.ALL ZohoCRM.org.ALL","api_domain":"https://www.zohoapis.com","token_type":"Bearer","expires_in":3600}
Have tried all of the scopes indicated in CRM API v4 docs.  I have also executed the same in curl and received the same API response.  All Output API responses (regardless of scopes) are returning:
Info
  • "{"code":"OAUTH_SCOPE_MISMATCH","details":{},"message":"invalid oauth scope to access this URL","status":"error"}"
Function executed successfully

Any ideas, help, direction would be greatly appreciated. I just don't know what I'm missing.  Thank you in advance!

  1. // Define API endpoint
  2. url = "https://www.zohoapis.com/crm/v4/settings/portals/PortalXXXXName/user_type";
  3. // Get OAuth access token using refresh token
  4. token_url = "https://accounts.zoho.com/oauth/v2/token?refresh_token=" + refresh_token + "&client_id=" + client_id + "&client_secret=" + client_secret + "&grant_type=refresh_token&scope=ZohoCRM.modules.ALL,ZohoCRM.settings.ALL";
  5. token_response = invokeurl
  6. [
  7. url: token_url
  8. type: POST
  9. ];
  10. // Check if token was obtained successfully
  11. if(token_response.get("error") != null)
  12. {
  13. info token_response.get("error");
  14. }
  15. else
  16. {
  17. // Extract OAuth access token from token response
  18. auth_token = token_response.get("access_token");
  19. // Make API request with auth token
  20. response = invokeurl
  21. [
  22. url: url
  23. type: GET
  24. headers:{"Authorization":"Zoho-oauthtoken " + auth_token}
  25. ];
  26. // Output API response
  27. info response;
  28. }