Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7404573
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:16:27+00:00 2026-05-29T05:16:27+00:00

I am trying to to use the latest version of the Report API using

  • 0

I am trying to to use the latest version of the Report API using OAuth 2. It doesn’t appear that there are many people using this version yet, so it has been really hard to find examples.

I have a refresh token, which I am using to generate an access token.

private AnalyticsService getAnalyticsService()
{
    AuthorizationServerDescription description = new AuthorizationServerDescription();
    description.TokenEndpoint = new Uri(login.TokenEndpoint);
    description.AuthorizationEndpoint = new Uri(login.AuthorizationEndpoint);
    WebServerClient client = new WebServerClient(description, login.ClientId, login.ClientSecret);

    OAuth2Authenticator<WebServerClient> authenticator = new OAuth2Authenticator<WebServerClient>(client, authenticate);
    AnalyticsService service = new AnalyticsService(authenticator);
    return service;
}

private IAuthorizationState authenticate(WebServerClient client)
{
    string[] scopes = new string[] { login.ScopeUrl }; // not sure if this is necessary
    IAuthorizationState state = new AuthorizationState(scopes) { RefreshToken = login.RefreshToken };

    client.RefreshToken(state);
    return state;
}

This appears to be working just fine:

{
 "access_token" : "ya29.AHES6ZQy67SSLHWJWGWcLbLn69yKfq59y6dTHDf4ZoH9vHY",
 "token_type" : "Bearer",
 "expires_in" : 3600
}

However, when I do a request, I am getting an error. For example, here
is a query that results in an error:

AnalyticsService service = getAnalyticsService();
ManagementResource.ProfilesResource.ListRequest request = service.Management.Profiles.List("~all", "~all");
return request.Fetch();

This is the error I get:

{"error":{"errors":[{"domain":"global","reason":"authError","message":"Invalid
Credentials","locationType":"header","location":"Authorization"}],"code":401,"message":"Invalid
Credentials"}}

I have tried other queries, providing valid profile IDs. However, I am
always getting a 401 error, saying I’m not authorized. I am having
trouble finding examples where people are using this code. It could be
something simple like a bad URL or something. Unfortunately, I have no
way to telling. It seems strange that I can get an access token, but I
can’t seem to perform any queries.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T05:16:28+00:00Added an answer on May 29, 2026 at 5:16 am

    With OAuth 2, the scope changed from:

    https://www.google.com/analytics/feeds/

    to:

    https://www.googleapis.com/auth/analytics.readonly

    You are getting the authentication error because you were trying to get access without the proper scope.

    Quick and easy fix.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to use jQuery (latest version) & ajax to poll a mysql
I am trying to use Google's Sketchup C++ SDK (latest version) to export a
Im trying to use msbuild to get the latest version of my code from
I'm trying to use the latest version of the jquery.ui.spinner.js . http://wiki.jqueryui.com/w/page/12138077/Spinner The spinners
I am trying to use the TFS API to retrieve the latest code from
I'm using the latest version of iTextSharp found here: http://sourceforge.net/projects/itextsharp/ I am trying to
I have been trying to use the latest NAnt (0.86 Beta 1) for a
I'm currently trying to use the latest stable fmod ex in my project. I
I'm trying to use the Metakit library latest update, but I always get an
I'm trying to use an open-source project. Both the latest official (from a *.tar.gz

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.