google-api-php-client: Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential

Hello all I’m trying to reach google analytics scope in order to get the total visitors to my sit but i get this error when I use the json file of Outh 2.0 in the setConfig method

{
    "error": {
        "code": 401,
        "message": "Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
        "errors": [
            {
                "message": "Login Required.",
                "domain": "global",
                "reason": "required",
                "location": "Authorization",
                "locationType": "header"
            }
        ],
        "status": "UNAUTHENTICATED",
        "details": [
            {
                "@type": "type.googleapis.com/google.rpc.ErrorInfo",
                "reason": "CREDENTIALS_MISSING",
                "domain": "googleapis.com",
                "metadata": {
                    "service": "analyticsreporting.googleapis.com",
                    "method": "google.analytics.reporting.v4.Reporting.GetReports"
                }
            }
        ]
    }
}

Why this happened i need to know

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 15 (5 by maintainers)

Most upvoted comments

I’ll reply with an example tomorrow. If I don’t send me a dm

On Mon, 18 Sep 2023 at 17:22, oolul @.***> wrote:

Sorry @benrcole https://github.com/benrcole I’m not sure to understand what you’re suggesting.

I’ve tried to do it with the library (v2.14.0 and v2.15.1) and it failed. After that I tried to do manual requests myself and still having the same error at the same step of the process and I can tell you that I’m sure that the Authorization header is present on my request.

What I’ve tried to make sure my access_token was valid is to put a fake one when I try to fetch an asset or update the match policy and it failed so that confirms that my access_token is valid or at least for those endpoints…

Could you be more explicit of what works for you ? And are you doing a reference file upload too ?

Thanks

— Reply to this email directly, view it on GitHub https://github.com/googleapis/google-api-php-client/issues/2479#issuecomment-1723696165, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAWOZT6FY4QTYLDFKTZXBY3X3BRKDANCNFSM6AAAAAA2YBCBQQ . You are receiving this because you were mentioned.Message ID: @.***>