Seguí http://googlemac.blogspot.com/2011/05/ios-and-mac-sign-in-controllers.html para permitir a los usuarios usar Google para iniciar sesión en una aplicación de iPhone. Después de tocar el botón "Permitir acceso" obtengo una pantalla adicional que dice, "Copie este código, cambie a su aplicación y péguelo allí: (código en un cuadro de texto)".Cómo evitar que la vista adicional muestre un código de acceso al utilizar Google OAuth 2.0
Esto es lo que tengo:
- (IBAction)googleLoginTapped:(UIButton *)sender
{
[self loginToGoogle];
}
- (void)loginToGoogle
{
// For Google APIs, the scope strings are available
// in the service constant header files.
NSString *scope [email protected]"https://www.googleapis.com/auth/userinfo.profile";
// Typically, applications will hardcode the client ID and client secret
// strings into the source code; they should not be user-editable or visible.
// But for this sample code, they are editable.
NSString *clientID = @"my clientID";
NSString *clientSecret = @"my clientSecret";
// Display the autentication view.
SEL finishedSel = @selector(viewController:finishedWithAuth:error:);
GTMOAuth2ViewControllerTouch *viewController;
viewController = [GTMOAuth2ViewControllerTouch controllerWithScope:scope
clientID:clientID
clientSecret:clientSecret
keychainItemName:nil
delegate:self
finishedSelector:finishedSel];
// For this sample, we'll force English as the display language.
NSDictionary *params = [NSDictionary dictionaryWithObject:@"en"
forKey:@"hl"];
viewController.signIn.additionalAuthorizationParameters = params;
// Optional: display some html briefly before the sign-in page loads
NSString *html = @"<html><body bgcolor=silver><div align=center>Loading sign-in page...</div></body></html>";
viewController.initialHTMLString = html;
viewController.signIn.shouldFetchGoogleUserProfile = YES;
[self presentModalViewController:viewController animated:YES];
}
- (void)viewController:(GTMOAuth2ViewControllerTouch *)viewController finishedWithAuth:(GTMOAuth2Authentication *)auth error:(NSError *)error
{
if (error != nil)
{
// Authentication failed (perhaps the user denied
favor ver este enlace es de buena https://developers.google.com/accounts/docs/OAuth2InstalledApp
@kevlar tiene la respuesta correcta – 2cupsOfTech