function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
ChrisDevOzChrisDevOz 

Google Calendar API 401 Unkown Authorization Header - OAuth

Hi All

 

So, I've spent most of the day trying to work through this, but as yet have had no luck.

 

I'm trying to use the Google API, authenticated with OAuth, to pull down a subset of calendar events.

 

I'm using the Salesforce.com OAuth Playground to take care of the heavy lifting, which up til now has worked ok.

 

If I submit the following GET request,

 

https://www.google.com/calendar/feeds/default/private/full?max-results=24&prettyprint=true

 

I have no problem, and I get the appropriate ATOM feed returned.

 

However, If I modify the request to something like,

 

https://www.google.com/calendar/feeds/default/private/full?max-results=24&prettyprint=true&start-min=2011-03-24T23:59:59

 

I get the 401 Unkown Authorization Header response.  It turns out that any query parameter that has a date/time value causes this error!

 

Both queries work fine using the Google OAuth Playground, and the Signature base strings for both the Salesforce.com & Google requests look correct.

 

I am using anonymous consumer key/secret and HMAC-SHA1 signature method.

 

I know it's a long shot, but if anyone else has come across this, or has any suggestions please let me know.

 

Cheers

 

Chris

Best Answer chosen by Admin (Salesforce Developers) 
ChrisDevOzChrisDevOz

Found the problem, the OAuth Playground is double encoding parameters.  You won't notice it on things like  max-results=25 or prettyprint=true as the encoding doesn't affect them, but something like start-min=2011-03-24T23:59:59 means you run into all kinds of problems.  see the difference between the Google OAuth Playground, vs the Salesforce output.

 

Google OAuth:
start-min%3D2011-03-24T23%3A59%3A59

Salesforce OAuth:
start-min%3D2011-03-24T23%253A59%253A 59

 

Haven't written a fix for it yet, but 99.99% sure this is the problem.