Request had invalid authentication credentials - Google Calendar API - oauth-2.0

I'm trying to to a request to the Google Calendar API using Postman. Following this Google documentation:
https://developers.google.com/calendar/v3/reference/?apix=true
I'm doing a:
GET https://www.googleapis.com/calendar/v3/calendars/{my_calendar_id_here}
On the Postman Authorization tab i'm specifying that i want to use OAuth 2.0 and i also put my access token (which i use to make Calendar API calls from code, works fine). However, Postman responds with the following body:
{
"error": {
"code": 401,
"message": "Request had invalid authentication credentials. 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": "Invalid Credentials",
"domain": "global",
"reason": "authError",
"location": "Authorization",
"locationType": "header"
}
],
"status": "UNAUTHENTICATED"
}
}
I really don't understand what i'm doing wrong, and other answers don't seem to target my particular scenario. I'd be grateful if someone could point out what am i doing wrong.

I would recommend replicating the request in Google's OAuth 2.0 Playground. Then using the confirmed to be working access token to troubleshoot Postman.
For Postman you could also pass the access token as a request header and if that resolves the issue.
Postman Headers Tab Input:
| Key | Value |
|---------------|-----------------------|
| Authorization | Bearer {access_token} |

Related

Twitter API Oauth2 issue getting Access Token

Following this guide: https://developer.twitter.com/en/docs/authentication/oauth-2-0/user-access-token. I am getting this error when making the POST oauth2/token at the step 3 request:
`
{
"errors": [
{
"code": 99,
"message": "Unable to verify your credentials",
"label": "authenticity_token_error"
}
]
}
`
This is my request: (Note that I hide the client_id and code). The code is the one I receive after the step 2, doing the GET oauth2/authorize callback. Header: Content-Type - application/x-www-form-urlencoded;charset=UTF-8
My Request
I found the issue, the problem was that in the Bot Application, editing the Auth settings of my twitter app, I had the option: Confidential client which needed a Basic Auth = authorization: Basic ${'username + password encoded here'}

Is delegation deprecated in Auth0?

I'm trying to POST to a Auth0 delegation URL to obtain an access token and getting a "Grant Type not allowed" error as seen below. (This is when not using Postman.)
I came across a post in the forums that Delegation is deprecate in Auth0. Can anyone confirm if that is the issue here and if I'm trying something that's not available anymore?
Request:
Content-Type: 'application/json'
{
"client_id": "ID",
"grant_type": "urn:ietf:params:oauth:grant-type:jwt-bearer",
"id_token": "TOKEN",
"target": "lwTL1rYVfC0KsBUFPeKWY3HvGjbIgdDM",
"api_type": "salesforce_api",
"scope": "openid"
}
Error:
{
"error": "unauthorized_client",
"error_description": "Grant type 'http://auth0.com/oauth/legacy/grant-type/delegation/id_token' not allowed for the client.",
"statusCode": 403,
"error_uri": "https://auth0.com/docs/clients/client-grant-types"
}
Related Question:
"Missing grant-type parameter" in Auth0 Delegation endpoint call
In that question, using Postman to call the endpoint with the same request results in a different error!

Google blogger api and expired secret key.

I have already managed to add some posts to my blog using google api and oauth and ran into some problems. I have tried for days - or weeks - to find the best question to ask and I believe I have isolated the problem. Apparently the secret key only works only for one hour. but after an hour at this line:
$service->blogs->getByUrl("theurlofmyblog.blogspot.com");
I get this error:
Google_Service_Exception in REST.php line 118:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "authError",
"message": "Invalid Credentials",
"locationType": "header",
"location": "Authorization"
}
],
"code": 401,
"message": "Invalid Credentials"
}
}
Some of the experts on forums have suggested that one must go to this address https://developers.google.com/oauthplayground/ and get a referesh token. But nobody has mentioned that how should we use that token. Do I put it inside the json file? There must be something like this - don't laugh please, this is supposed to be a suedo code -:
if(the key is expired)
use my referesh key and get me another key
Any experience?
As described in Google’s OAuth 2.0 documentation, you should receive a refresh token during the authentication flow. You should store that token someplace, then use it to get a new access token when necessary.
The exact procedure to exchange a refresh token for a new access token will depend on what OAuth client library you are using. In Signet (Google’s OAuth library for Ruby), for example, it’s done as part of fetch_access_token.

Using postman + oauth2 to access Google Apps Admin SDK

I am struggling to get oauth2 working between postman and the Google Apps Admin Sdk. I have created a client app in the google console and set the Authorized redirect URIs to https://www.getpostman.com/oauth2/callback and my settings in postman are as follows
Auth URL - https://accounts.google.com/o/oauth2/v2/auth
Access Token URL - https://www.googleapis.com/oauth2/v4/token
Client Id - some id here
Client Secrent - some secret here
Scope - https://www.googleapis.com/auth/admin.directory.user.readonly
Token Name - Google
Grant Type - Authorization Code
Request Access Token Locally - Checked
This returns a token - xyz - after logging in.
I do a GET request with the token in the url
https://www.googleapis.com/admin/directory/v1/users?key=xyz
The error I am getting is below
{
"error": {
"errors": [
{
"domain": "global",
"reason": "required",
"message": "Login Required",
"locationType": "header",
"location": "Authorization"
}
],
"code": 401,
"message": "Login Required"
}
}
From what I have read this should work. Where else do I have to login? What am I doing wrong?
After playing around I figured out my url was incorrect. Changing key to access_token did the trick.
Just a side note, ensure you specify the domain or customer parameter otherwise you will receive a bad request error.

forbiddenScope Error : while adding person in Google Plus circle via HTTP request

I want to add user in circle. I have retrieved access_token as described in Using OAuth 2.0 to Access Google APIs with scopes :
https://www.googleapis.com/auth/plus.me
https://www.googleapis.com/auth/plus.circles.read
https://www.googleapis.com/auth/plus.circles.write
https://www.googleapis.com/auth/plus.stream.write
Then i am calling HTTP request as described in Circles: addPeople
https://www.googleapis.com/plusDomains/v1/circles/<circleId>/people?userId=<userID>
but in response i am getting -
{
"error": {
"errors": [
{
"domain": "plusDomains",
"reason": "forbiddenScope",
"message": "Access to the Google+ Domains API is not allowed as the user has consented to incompatible scopes. See: https://developers.google.com/+/domains/authentication/."
}
],
"code": 403,
"message": "Access to the Google+ Domains API is not allowed as the user has consented to incompatible scopes. See: https://developers.google.com/+/domains/authentication/."
}
}
I have enabled Google+ API, Google+ Domains API in project's API's & Auth section.
Thanks in advance!

Resources