I finally got it figured out (mostly)
I've found that the documentation is really annoying, since it's trying to sell you the APIs when you're just looking for simple authentication and authorization. (Incidentally, I'm only using OAuth for authentication, and I'm authorizing on my own). The pages are each written nicely, but the links are a mess.
I've found the following two links to be most useful:
Overview
Playground
Of course, Google also gives you some "help" by providing example java clients (or your preferred fill in the blank back end service)
Turns out the first step to getting the access code is stupid. You just put a link with the right queryparams and Google pulls through that part for you, giving you the auth code as a get query parameter in the redirect uri. The next part was the annoying part for me.
Since I have a restful web service, I needed to do another post request with the auth code that Google gave me and send my client id and secret back to Google. I bootlegged a vanilla java post request thing from the web and muscled through it. It uses HttpsUrlRequest or something.
Be sure that your parameters are correct here, Google likes to throw 400s when you misbehave.
Two examples:
- you try to post twice. It'll only work if you get it right on the first try. If you mess up, you have to re-authorize.
- if you mess up the redirect uri. I'm dumb.
Finally, you get the access_token.
You do another call with that to get the info. This call is easy (finally).
You celebrate, as you've gotten the info from Google that you need. Now everything is handed back to your application.
More to come! As I figure the rest out.
No comments:
Post a Comment