I am trying to use a Server API Key following the instructions at https://developers.google.com/console/help/new/#generatingdevkeys
I have generated a key and whitelisted my IPs (tried from two different ones so far).
However, every response I send results in 401 Unauthorized. My HTTP request looks like this:
Request from an IP associated with the key
POST https://www.googleapis.com/prediction/v1.6/projects/652546152834/hostedmodels/website/predict?key={MY_API_KEY_IS_HERE} HTTP/1.1
User-Agent: Fiddler
Host: www.googleapis.com
Content-Length: 0
Response
{
"error": {
"errors": [
{
"domain": "global",
"reason": "required",
"message": "Login Required",
"locationType": "header",
"location": "Authorization"
}
],
"code": 401,
"message": "Login Required"
}
}
Am I missing a step? I'd prefer not to use OAuth since it seems like overkill for my simple scenario, but I'll do that next if there's no solution here.
Your application must use OAuth 2.0 to authorize requests. No other authorization protocols are supported.
Source
Related
I am trying to get the full list of my own channel's subscribers, but this does not work.
https://www.googleapis.com/youtube/v3/subscriptions?part=snippet&mine=true&key=[API_KEY]
I am following the official documentation https://developers.google.com/youtube/v3/docs/subscriptions/list
But get this error
{
"error": {
"code": 401,
"message": "The request uses the \u003ccode\u003emine\u003c/code\u003e parameter but is not properly authorized.",
"errors": [
{
"message": "The request uses the \u003ccode\u003emine\u003c/code\u003e parameter but is not properly authorized.",
"domain": "youtube.parameter",
"reason": "authorizationRequired",
"location": "mine",
"locationType": "parameter"
}
]
}
}
Currently you are only using an api key which will only give you access to public data, using mine is private user data and will require authorization.
This can be seen in the documentation page for
Subscriptions: list States
This means that you must be authorized using Oauth2 to access the subscriptions for this channel. You will then have an access token that you can send as an authorization header bearer token.
GET https://youtube.googleapis.com/youtube/v3/subscriptions?part=snippet&mine=true&key=[YOUR_API_KEY] HTTP/1.1
Authorization: Bearer [YOUR_ACCESS_TOKEN]
Accept: application/json
I'm trying to use Push notifications for Google Calendar
Callback endpoint is hosted on Heroku. appname.herokuapp.com is verified in Search Console and added to Google Console APIs & Services Allowed domains list.
Request
POST /calendar/v3/calendars/CALENDAR_ID/events/watch HTTP/1.1
Host: www.googleapis.com
Authorization: Bearer TOKEN
Content-Type: application/json
{
"id":"1",
"type": "web_hook",
"address":"https://APPNAME.herokuapp.com/change"
}
Response
400 Bad Request
{
"error": {
"errors": [
{
"domain": "push",
"reason": "channelUnknown",
"message": "WEB_HOOK channel unavailable for:
{address=https://APPNAME.herokuapp.com/change}"
}
],
"code": 400,
"message": "WEB_HOOK channel unavailable for: {address=https://APPNAME.herokuapp.com/change}"
}
}
What
WEB_HOOK channel unavailable
error means?
EDIT: same result with a top level domain which certificate's Subject matches exactly the domain name.
It appears that this was a temporary issue and is now fixed according to Google. (I also tested and seems to be working for me, now.)
I am gating this Error when i use Youtube API
{
"error": {
"errors": [
{
"domain": "usageLimits",
"reason": "ipRefererBlocked",
"message": "The request did not specify any referer. Please ensure that the client is sending referer or use the API Console to remove the referer restrictions.",
"extendedHelp": "https://console.developers.google.com/apis/credentials?project=************"
}
],
"code": 403,
"message": "The request did not specify any referer. Please ensure that the client is sending referer or use the API Console to remove the referer restrictions."
}
}
and 403() error it's showing in console
I'm using the API Explorer tool to create some request urls for google adsense. Here is the request url that the explorer tool generated that gives a response of today's earnings: https://www.googleapis.com/adsense/v1.4/reports?startDate=today&endDate=today&accountId=MY_ACCOUNT_ID&metric=EARNINGS&key=MY_API_KEY
However, when I try to use this url in the browser or in my code it gives this response:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "required",
"message": "Login Required",
"locationType": "header",
"location": "Authorization"
}
],
"code": 401,
"message": "Login Required"
}
}
I am not sure what I am missing it use this url. I have activated adsense apis on my google developer console.
The key parameter is the public API key for accessing public data.
The access_token parameter is used for accessing private user data.
In your case you are trying to access your private account and should be using an access token.
To obtain an access token you need to authentication your application using either Oauth2 or a service account. Once you have obtained an access token and send that with your request as so:
https://www.googleapis.com/adsense/v1.4/reports?startDate=today&endDate=today&accountId=MY_ACCOUNT_ID&metric=EARNINGS&access_token=YourAccessToken
You need to replace MY_API_KEY with your API key, and MY_ACCOUNT_ID in same fashion.
The LicenseAssignments.get api returns 200 OK
Request:
GET https://www.googleapis.com/apps/licensing/v1/product/Google-Apps/sku/Google-Apps-For-Business/user/<email>
Response:
200 OK
- Show headers -
{
"kind": "licensing#licenseAssignment",
"selfLink": "https://www.googleapis.com/apps/licensing/v1/product/Google-Apps/sku/Google-Apps-For-Business/user/<email>",
"userId": "<email>",
"productId": "Google-Apps",
"skuId": "Google-Apps-For-Business"
}
However LicenseAssignments.listForProduct returns "403 Forbidden"
Request:
GET https://www.googleapis.com/apps/licensing/v1/product/Google-Apps/users?customerId=my_customer
Response:
403 Forbidden
- Show headers -
{
"error": {
"errors": [
{
"domain": "global",
"reason": "forbidden",
"message": "Unauthorized operation for the given domain."
}
],
"code": 403,
"message": "Unauthorized operation for the given domain."
}
}
Any idea why I get 403 forbidden for the second request?
This issue got resolved when I used 'domain name' (e.g. something.com) as 'customerId'. This is different from the usual behavior of other Google APIs where 'customerId' is 'my_customer'.
https://www.googleapis.com/apps/licensing/v1/product/Google-Apps/users?customerId=<domain name>