hidden heading

  • Threads
  • Categories
  • Users
  • Blog
  • forum
  • group
  • search
  • chevron_right Threads
  • label Code Implementation

API request refused with "Request had insufficient authentication scopes"

mmadhu
Sept. 21, 2023
chat_bubble_outline 2
  • link
    mmadhu
    Members 24 posts
    Sept. 21, 2023, 10:25 a.m. Sept. 21, 2023, 10:25 a.m.
    link

    The service account generated according to the Java API GA4 quickstart guide lacks the necessary authentication scopes to grant access to the associated GA4 Account and Property, as indicated in the Service Account .json file.

    As a result, utilizing the API to fetch analytics metrics in Java becomes unfeasible.

  • link
    agkhy
    Mod 110 posts
    Sept. 21, 2023, 10:27 a.m. Sept. 21, 2023, 10:27 a.m.
    link

    I encountered persistent issues when attempting to use the Java client library, consistently encountering the same error. However, I found success when I utilized the Python library with the same Service Account JSON credentials.

  • link
    agkhy
    Mod 110 posts
    Oct. 3, 2023, 8:33 a.m. Oct. 3, 2023, 8:33 a.m.
    link

    This was solved by using a different GA4 Data API Java method to obtain the required credential from the client_secrets.json file. See

    stackoverflow.com/questions/76882694/google-analytics-4-api-service-account-has-full-admin-privileges-still-permi/77106015#77106015

    In essence, in my code as at the above location I needed to replace

    GoogleCredentials gc = ServiceAccountCredentials.fromStream(this.getClass().getResourceAsStream("/client_secrets.json")).createScoped(Collections.singletonList(StorageScopes.DEVSTORAGE_FULL_CONTROL));

    with

    GoogleCredentials gc = GoogleCredentials.fromStream(this.getClass().getResourceAsStream("/client_secrets.json"));

    to solve the "insufficient authentication scopes" error.

There are no more posts in this thread.

easyinisghts_logo
likedininstagrammediumtwitter

Singapore
14-04 160 Robinson Rd,
Singapore - 068914

India
619/2-7, Chattarpur,
Delhi, 110074

Join our Newsletter

Become a data driven marketer

Resources

  • Knowledge Base
  • Blogs
  • Ebooks
  • Contact Us
  • Use Cases

Join our Newsletter

Become a data driven marketer

Singapore
14-04 160 Robinson Rd,
Singapore - 068914

India
619/2-7, Chattarpur,
Delhi, 110074

© 2024 EasyInsights. All rights reserved. | ® EasyInsights Pvt. Ltd.