What redirect uri should I use (OAuth 2.0)?
oauth, objective-c
Solution
You should learn first about oAuth.
Generally, the 1st link is the authorize flow - you call it and get a code. The 2nd URL is to get the token using the code you got from the previous URL.
Explaining how exactly to work with oAuth is out of the scope here, but you have many places you can read and learn.
Problem
I register my application for google API Console. And I get my client secret,client ID,and two redirect uris. ``` //● urn:xxxxxxx:oob //● http://localhostxxxxxx ``` Of course I use these items and succeed to request token to google. But when I click Authorization button(like "do you want to authorize this application?" Yes), two response occur. If I use urnxxxxxx, I get "The operation couldn't be completed. (com.google.HTTPStatus error 404.)". ``` //Or If I use http://localhostxxxxxxxxxxxxx and click Yes button, then nothing happens. ``` What should I do Next? (The following code is for google reader.) ``` #import "MasterViewController.h" #import "DetailViewController.h" #import "GTMOAuth2Authentication.h" #import "GTMOAuth2ViewControllerTouch.h" #import "GTMOAuth2WindowController.h" static NSString *const kKeychainItemName = @"Greader"; @interface MasterViewController () { NSMutableArray *_objects; } @end @implementation MasterViewController - (IBAction)authentication:signInToGoogle:(id)sender; {} - (GTMOAuth2Authentication * ) authForGoogle { NSString * url_string = @"http://www.google.com/reader/api/"; NSURL * tokenURL = [NSURL URLWithString:url_string]; NSString * redirectURI = @"xxxxoob"; GTMOAuth2Authentication * auth; auth = [GTMOAuth2Authentication authenticationWithServiceProvider:@"reader" tokenURL:tokenURL redirectURI:redirectURI clientID:@"xxxxx" clientSecret:@"xxxx"]; auth.scope = @"http://www.google.com/reader/api/"; return auth; } - (void)signInToGoogle { GTMOAuth2Authentication * auth = [self authForGoogle]; NSString* auth_string = @"https://accounts.google.com/o/oauth2/auth"; NSURL * authURL = [NSURL URLWithString:auth_string]; GTMOAuth2ViewControllerTouch * viewController; viewController = [[GTMOAuth2ViewControllerTouch alloc]initWithAuthentication:auth authorizationURL:authURL keychainItemName:kKeychainItemName delegate:self finishedSelector:@selector(viewController:finishedWithAuth:error:)]; [self.navigationController pushViewController:viewController animated:YES]; } ```