Re: Exchanging Access Code for Access Token

116 views
Skip to first unread message

Greg Robbins

unread,
Oct 15, 2012, 2:49:59 PM10/15/12
to gtm-o...@googlegroups.com
The GTM OAuth 2 library does the exchange of a refresh token for an access token automatically. It can add the access token to the headers of an NSMutableURLRequest for use with NSURLConnection, or can be used to authorize requests made with the GTM HTTP Fetcher class.


Greg Robbins

unread,
Oct 15, 2012, 3:05:53 PM10/15/12
to gtm-o...@googlegroups.com
The GTM OAuth 2 sign-in controller automatically does the exchange of the access code during the sign-in flow. When an application uses the controller, the user should not see an html page with the access code, nor does the application need to care about the access code.

Tom Chokel

unread,
Oct 15, 2012, 3:45:47 PM10/15/12
to gtm-o...@googlegroups.com

So in my login controller, I have implemented the following method. 

- (void)viewController: finishedWithAuth: error:

It is not giving any errors; however, the [auth canAuthorize] method returns false and when I print out [auth description] it only shows me the authentication code value. Where should I retrieve the authentication token value?

Thanks so much for your help!

Greg Robbins

unread,
Oct 15, 2012, 3:53:46 PM10/15/12
to gtm-o...@googlegroups.com
The authorizeRequest: method of GTMOAuth2Authentication does the exchange of a refresh token for an access token, when needed.

The sample application included with the controllers has a doAnAuthenticatedAPIFetch method to demonstrate using the auth object. 

The controllers have been used primarily with Google's auth servers; if you are authenticating to a different service provider, they may not be returning the tokens in a compatible way.

Tom Chokel

unread,
Oct 15, 2012, 6:25:19 PM10/15/12
to gtm-o...@googlegroups.com
Ah that example was exactly what I was looking for.

Thanks for your help!
Reply all
Reply to author
Forward
0 new messages