why is google oauth2 playground failing to return

2019-02-24 18:41发布

问题:

I'm learning oauth2 using the google playground, I'm trying this request:

https://www.googleapis.com/youtube/v3/activities?part=snippet

and receiving this response:

{
  "error": {
    "code": 403, 
    "message": "Access Not Configured. Please use Google Developers Console to activate the API for your project.", 
    "errors": [
      {
        "domain": "usageLimits", 
        "message": "Access Not Configured. Please use Google Developers Console to activate the API for your project.", 
        "reason": "accessNotConfigured"
      }
    ]
  }
}

on the authorization tab I requested access to all yoututbe v3 api scopes and I granted access upon request. I'm assuming I'm forming the query parameters wrong perhaps? I'm new to oauth and how anything about it works.

回答1:

I believe you need to use your own oauth clientID and secret for this particular API in the playground. If you click on the gear button on the right top corner and click the check mark on "Use your own credential" in the playground, you should be able to enter yours.

You can get your own OAuth credential by following the instruction here: https://developers.google.com/youtube/registering_an_application

Oh make sure you name your application and provide email under the APIS & AUTH ->Consent screen in the Developer console when you first create you OAuth credential for your project.

And there is one thing missing in your query as well... you need specify a filter as well. See if you can at least get this one working:

GET https://www.googleapis.com/youtube/v3/activities?part=snippet&home=true



回答2:

I had the same issue, and before I found your question I had posted mine

Apparently Google hadn't enabled the Youtube Analytics API for the default/demo credentials in the oAuthPlayground, which is now enabled, see the accepted answer in the link

https://stackoverflow.com/a/33462959/2473413