Как предотвратить отображение кода доступа в дополнительном представлении при использовании Google OAuth 2.0

Я подписался на http://googlemac.blogspot.com/2011/05/ios-and-mac-sign-in-controllers. html , чтобы пользователи могли использовать Google для входа в приложение iPhone. После нажатия кнопки «Разрешить доступ» появляется дополнительный экран с надписью «Скопируйте этот код, переключитесь в свое приложение и вставьте его туда: (код в текстовом поле)».

Это то, что у меня есть :

- (IBAction)googleLoginTapped:(UIButton *)sender
{
    [self loginToGoogle];
}

- (void)loginToGoogle 
{

    // For Google APIs, the scope strings are available
    // in the service constant header files.
    NSString *scope =@"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 = @"
Loading sign-in page...
"; 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

пожалуйста, посмотрите эту ссылку, это хорошо https://developers.google.com/accounts/docs/OAuth2InstalledApp

11
задан Sourabh Sharma 7 May 2015 в 11:03
поделиться