I’m currently trying to access a Google service via a Chrome extension. My understanding is that for JS apps Google’s preferred authentication mechanism is OAuth. My app currently successfully authenticates via OAuth to the service.
The preferred mechanism to query the service is via SOAP. However SOAP has it’s own ‘auth token’ concept which is set in the body of the XML. I do not have a old-style ‘ClientLogin’ token to use per Google’s docs.
How can I run SOAP queries using my OAuth-authenticated access token? Or should I be using different mechanism to query or authenticate?
Answering myself:
Authenticate to OAuth via the normal mechanism, ie, in JS:
Then authenticate and run your SOAP requests as a callback:
The SOAP header is a smaller version of what’s documented, omitting the fields that are only necessary for ClientLogin API.
Body is per normal.
Then POST this using the appropriate method (oauth.sendSignedRequest in JS) that will add the required OAuth fields to the query string:
Done. If you need to do the query manually rather than use sometong like sendSignedRequest, it looks like:
TLDR: OAuth in query string, omit all auth info from SOAP header.