How to pre-fill email account when creating the auth controller for authorizing access to Google Calendar API

44 views
Skip to first unread message

Allen Z.

unread,
Aug 2, 2016, 7:59:28 AM8/2/16
to GTM OAuth 2 Discussion

Hi guys,

I am working on access to Google Calendar to retrieve events from a user specified google account.

When my APP knows which user's account it is trying to authenticate, how can I provide this parameter to the Authentication Server and pre-filling the email box on the sign-in form? Does anyone solve similar problem I am facing now? Thanks.


Used Pods to download Calendar API and GTMOAuth2 sources. 

pod 'GoogleAPIClient/Calendar', '~> 1.0.2'

    pod 'GTMOAuth2', '~> 1.1.0'


I followed below sample codes for authoring access google account.

// Creates the auth controller for authorizing access to Google Calendar API.

- (GTMOAuth2ViewControllerTouch *)createAuthController {

    GTMOAuth2ViewControllerTouch *authController;

    // If modifying these scopes, delete your previously saved credentials by

    // resetting the iOS simulator or uninstall the app.

    NSArray *scopes = [NSArray arrayWithObjects:kGTLAuthScopeCalendar, nil];

//    NSArray *scopes = [NSArray arrayWithObjects:kGTLAuthScopeCalendarReadonly, nil];

    authController = [[GTMOAuth2ViewControllerTouch alloc] initWithScope:[scopes componentsJoinedByString:@" "] clientID:kClientID clientSecret:nil keychainItemName:kKeychainItemName delegate:self finishedSelector:@selector(viewController:finishedWithAuth:error:)];

    return authController;

}

Allen Z.

unread,
Aug 3, 2016, 8:05:55 AM8/3/16
to GTM OAuth 2 Discussion
Hi guys, does anyone solve the similar problems I am facing now?

Thomas Van Lenten

unread,
Aug 4, 2016, 1:28:59 PM8/4/16
to GTM OAuth 2 Discussion
I believe this has come up in the past also, and the answer is there really isn't a way (there might have been a way to hint it, but the user still had to act to accept it).  The objects we provide do let you get back the user name after signin, so can you flip your flow and have them select "google" for the signin, show the controller, and collect the address at the end?

TVL
Reply all
Reply to author
Forward
0 new messages