I decided to bypass the API for oAuth and do it myself.
The user must copy the authentication code and paste it into my application - this is not the first choice, but they need to do this only once, and this is preferable to the alternative (absence).
Code sharing for those interested:
When a user selects Google Drive:
window.open('https://accounts.google.com/o/oauth2/auth?' + 'client_id=<some value>' + '&scope=<space delimited list of permissions>' + '&redirect_uri=urn:ietf:wg:oauth:2.0:oob' + '&response_type=code');
This creates a popup that allows them to resolve and presents them with auth code.
When an authentication code is inserted into my application, I save it in the database and continue to receive the access code, which I then save in the database:
$.ajax({ url: "https://accounts.google.com/o/oauth2/token", type: 'post', data: { code: <authCode>, client_id: CLIENT_ID, client_secret: CLIENT_SECRET, redirect_uri: 'urn:ietf:wg:oauth:2.0:oob', grant_type: 'authorization_code' } }).error(function(data) { myObj.isAuth = false; if (cbFail) { cbFail(data); } }).success(function(data) { myObj.isAuth = true; <persist entire response> if (cbSuccess) { cbSuccess(); } });
source share