Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to prevent the extra view displaying an access code when using Google OAuth 2.0
    text
    copied!<p>I followed <a href="http://googlemac.blogspot.com/2011/05/ios-and-mac-sign-in-controllers.html" rel="nofollow">http://googlemac.blogspot.com/2011/05/ios-and-mac-sign-in-controllers.html</a> to allow users to use Google to login to an iPhone app. After I tap "Allow access" button I get an extra screen that says, <strong>"Please copy this code, switch to your application and paste it there: (code in a textbox)."</strong></p> <p>This is what I have:</p> <pre><code>- (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 = @"&lt;html&gt;&lt;body bgcolor=silver&gt;&lt;div align=center&gt;Loading sign-in page...&lt;/div&gt;&lt;/body&gt;&lt;/html&gt;"; 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 </code></pre> <p>please see this link it is to good <a href="https://developers.google.com/accounts/docs/OAuth2InstalledApp" rel="nofollow">https://developers.google.com/accounts/docs/OAuth2InstalledApp</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload