Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Xcode 4.2 storyboard and GTMOAuth2ViewControllerTouch
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Jorge Luis Mendez  
View profile  
 More options Apr 13 2012, 6:17 pm
From: Jorge Luis Mendez <jo...@jorgemendez.me>
Date: Fri, 13 Apr 2012 15:17:40 -0700 (PDT)
Local: Fri, Apr 13 2012 6:17 pm
Subject: Xcode 4.2 storyboard and GTMOAuth2ViewControllerTouch

Hi,

Apologize for cross posting but I mistakenly used the wrong list.

I've been trying to figure out a clean way to use *
GTMOAuth2ViewControllerTouch* with storyboards without much success.

The problem is that I can't find how to initialize *
GTMOAuth2ViewControllerTouch* properly since it must use "*(id)initWithScope:(NSString
*)scope clientID:(NSString *)clientID...*". According to Apple's
documentation the view controller's life cycle with Storyboards invokes *initWithCoder:
* and, if it's not implemented, *init:*.[1<http://developer.apple.com/library/ios/featuredarticles/ViewControlle...>
]

Unless I'm missing something I think that the proper way to solve this
would be to implement init: (or initWithCoder: for that matter)
in GTMOAuth2ViewControllerTouch and synthesize the proper setters.

Cheers,
Jorge Luis


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
☃ David Phillip Oster  
View profile  
 More options Apr 16 2012, 6:36 pm
From: David Phillip Oster (☃) <os...@google.com>
Date: Mon, 16 Apr 2012 15:36:10 -0700
Local: Mon, Apr 16 2012 6:36 pm
Subject: Re: Xcode 4.2 storyboard and GTMOAuth2ViewControllerTouch

Implement your own subclass of *GTMOAuth2ViewControllerTouch* that
implements either initWithCoder: or init, calls and just calls the
appropriate [super initXXX with the correct arguments.

On Fri, Apr 13, 2012 at 3:17 PM, Jorge Luis Mendez <jo...@jorgemendez.me>wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
mpf  
View profile  
 More options Aug 21 2012, 11:46 pm
From: mpf <nico.fla...@gmail.com>
Date: Tue, 21 Aug 2012 20:46:17 -0700 (PDT)
Local: Tues, Aug 21 2012 11:46 pm
Subject: Re: Xcode 4.2 storyboard and GTMOAuth2ViewControllerTouch

It's actually much easier than than that. You just need another VC to call
GTMOAuth2ViewControllerTouch.

   - For a quick demo project: In storyboard, create a single
   viewController embedded in a navigation controller. create labels for
   whatever data you want to display (i.e. token, exp.date, email, service
   provider etc.) and a button to start the sign-in.
   - Create a  new viewController class and link it to the VC you created
   in storyboard. link the IBOutlets you created above. implement the
   following action for your start button. (make sure to include the
   GTMOAuth2ViewTouch.xib in your project even though you are using a
   storyboard) #import "GTMOAuth2ViewControllerTouch.h"
   - Implement the callback - (void)viewController:(
   GTMOAuth2ViewControllerTouch *)viewController finishedWithAuth:(
   GTMOAuth2Authentication *)auth error:(NSError *)error- at the end of
   which update your labels to the returned values

- (IBAction)signinButton:(UIButton *)sender {    

GTMOAuth2ViewControllerTouch *authVC = [[GTMOAuth2ViewControllerTouch alloc]
initWithScope:scope

                    clientID:kMyClientID

                clientSecret:kMyClientSecret

            keychainItemName:kKeychainItemName

                    delegate:self

            finishedSelector:@selector
(viewController:finishedWithAuth:error:)];

    [self.spinner startAnimating];

 [[self navigationController] pushViewController:authVC animated:YES];

}

- (void)viewController:(GTMOAuth2ViewControllerTouch *)viewController
finishedWithAuth:(GTMOAuth2Authentication *)auth error:(NSError *)error {

    if (error != nil) {

        // Authentication failed (perhaps the user denied access, or closed
the

        // window before granting access)

        NSLog(@"Authentication error: %@", error);

        NSData *responseData = [[error userInfo] objectForKey:@"data"]; //
kGTMHTTPFetcherStatusDataKey

        if ([responseData length] > 0) {

            // show the body of the server's authentication failure response

            NSString *str = [[NSString alloc] initWithData:responseData
encoding:NSUTF8StringEncoding] ;

            NSLog(@"%@", str);

        }

        self.auth = nil;

    } else {

        // Authentication succeeded

        //

        // At this point, we either use the authentication object to
explicitly

        // authorize requests, like

        //

        //  [auth authorizeRequest:myNSURLMutableRequest

        //       completionHandler:^(NSError *error) {

        //         if (error == nil) {

        //           // request here has been authorized

        //         }

        //       }];

        //

        // or store the authentication object into a fetcher or a Google
API service

        // object like

        //

        //   [fetcher setAuthorizer:auth];

        // save the authentication object

        self.auth = auth;

        NSLog(@"authorization=%@\nexpiration date=%@",self.auth.accessToken,
self.auth.expirationDate);

        self.serviceProviderLabel.text=self.auth.serviceProvider;

        self.clientEmailLabel.text=self.auth.userEmail;

        self.tokenLabel.text=self.auth.accessToken;

        self.expireDate.text=[self.auth.expirationDate description];

    }

    [self.spinner stopAnimating];

    //[self updateUI];


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions Older topic »