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!
1 Like
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
1 Like