robynp31
(robynp31)
April 4, 2022, 9:17am
1
Hi all,
I am just getting started with postman, and thought it would be a good idea to integrate with the Google Calendar API.
I got the POST part of the request right and it is returning a bearer token as expected. My issue comes in with the second GET request;
It returns 401 authentication error.
I have done some more investigation and believe whitespace to be the issue;
As can be seen from the cURL, it appears that Postman is automatically adds whitespace between the key-value pairs of the request. I have checked my entries and can find no whitespace there…
So my question is; is there a way to remove this whitespace that is added into my request before sending it?
w4dd325
(w4dd325)
April 4, 2022, 9:33am
2
Hi @robynp31
Looking at your screenshots, I suspect your bearer token is invalid, the header section looks too short.
How are you building your token?
robynp31
(robynp31)
April 4, 2022, 9:47am
3
Hi w4dd325,
I obtained my bearer token from the first API call;
Added header values according to an online guide😅
Get Access token from Google Calendar API through Postman While working with integration with third parties, it is very very important to get the access…
Est. reading time: 2 minutes
My suspicion is that the bearer token is incorrectly read due to the whitespace preceding it?
w4dd325
(w4dd325)
April 4, 2022, 10:12am
4
Does the curl command work if you send it from elsewhere?
for example; Run Curl Commands Online
robynp31
(robynp31)
April 4, 2022, 10:24am
5
Unfortunately not. It now returns error code 403
{
“error”: {
“code”: 403,
“message”: “Request had insufficient authentication scopes.”,
“errors”: [{
“message”: “Insufficient Permission”,
“domain”: “global”,
“reason”: “insufficientPermissions”
}],
“status”: “PERMISSION_DENIED”,
“details”: [{
“@type ”: “type.googleapis.com/google.rpc.ErrorInfo ”,
“reason”: “ACCESS_TOKEN_SCOPE_INSUFFICIENT”,
“domain”: “googleapis.com ”,
“metadata”: {
“method”: “calendar.v3.Calendars.Get”,
“service”: “calendar-json.googleapis.com ”
}
}]
}
}
robynp31
(robynp31)
April 4, 2022, 10:37am
6
Found my issue.
The scope for my bearer token was www.googleapis.com/auth/drive
The scope I needed for my GET request is www.googleapis.com/auth/calendar
Both request work without issue now.
Thank you so much for your assistance!
w4dd325
(w4dd325)
April 4, 2022, 10:37am
7
Hmmm …
I read the docs and I’m not sure…
But here are 2 workspaces that you could fork, they appear to have set up Google Calendar API’s;
Link 1
Link 2