2
votes

THE GIVEN URL:

https://accounts.google.com/o/oauth2/auth?scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.profile+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive&state=drive&redirect_uri=http%3A%2F%2Fwww.woktop.com%2Fnewservice.php&response_type=token&client_id=889314330670.apps.googleusercontent.com

THE RETURN URL:

http://www.woktop.com/newservice.php#state=drive&access_token=ya29.AHES6ZRtTRmpakw5qa0SejLsC0qzNNb9R6GYF0xZGt_uphe3WfeeZng&token_type=Bearer&expires_in=3600

The return URL completely works if the # is changed to a ? (to start the query string). Why in the world is Google returning a # and thus "killing the query string"?

SEPARATE NOTE:

On a separate note, I don't quite know if I should be requesting token or code as a response type. I'm planning to have users attach their Google Drive account(s) to an account on my website. I have read through the documentation multiple times and I can't quite figure out which one is better for my website? For now (in the example above) I go with token. Also, depending on which one I go with, what should I store in my database for future use?

1

1 Answers

4
votes

The reason is because I was requesting a token instead of a code. When I received code, the URL was formatted without a hash (#), but rather formatted as a query string. The reason for this is unclear to me, but the documentation states that token should only be used as a response type for a heavy-Javascript application. The API code I was writing is in PHP, so code is the clearly appropriate choice.