Git Product home page Git Product logo

gtm-oauth's Introduction

⚠️ Notice

This is a client library for OAuth 1.0. Google no longer supports OAuth 1.0. If you're looking for the modern Google OAuth 2.0 library for iOS, macOS, and tvOS, see GTMAppAuth.

GTM OAuth: Google Toolbox for Mac - OAuth 1.0 Controllers

Project site https://github.com/google/gtm-oauth
Discussion group http://groups.google.com/group/gtm-oauth

The Google Toolbox for Mac OAuth Controllers make it easy for Cocoa applications to sign in to services using OAuth 1.0 for authentication and authorization.

Features include:

  • Complete embedded user interface using WebKit
  • Works with Google APIs and with any standard OAuth 1.0 provider
  • Handles sign-in, keychain storage of authorization token, and signing of requests
  • Independent of other projects

To get started with GTM OAuth, read the wiki.

If you have a problem or want a new feature to be included in the library, please join the GTM-OAuth discussion group or submit an issue.

The library incorporates the GTM HTTP Fetcher project.

This project is for controllers for services using the OAuth 1.0 protocol. There is a separate project for OAuth 2.0 controllers.

Other useful classes for OS X and iOS developers are available in the Google Toolbox for Mac.

gtm-oauth's People

Contributors

gmrobbins avatar idf3d avatar thomasvl avatar williamdenniss avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gtm-oauth's Issues

Crash when OAuth window is dismissed

What steps will reproduce the problem?
1. Build & run
2. Complete OAuth login to Twitter
3. Crash

See:

https://groups.google.com/forum/#!topic/gtm-oauth/N6jlOpL9k5g

This line of code causes the crash:

- (void)destroyWindow {
  // no request; close the window (but not immediately, in case
  // we're called in response to some window event)
  [[self webView] stopLoading:nil]; <--- *** causes the crash
  . . .

Here's a stack trace of the crash:

2014-04-17 14:55:44.000 -0- Exception handler: Uncaught system exception: 
signal 11
2014-04-17 14:55:44.084 -0- Stack Trace:
#0  ExceptionHandling                   000140735561141361 
NSExceptionHandlerUncaughtSignalHandler()
#1  libsystem_platform.dylib            000140735578928554 _sigtramp()
#2  ??                                  000000004660728840 
+[SyncableObjectMO_SyncableObject_ _PFPlaceHolderSingleton]
#3  WebCore                             000140735485213608 
_ZN7WebCore14DocumentLoader14maybeLoadEmptyEv()
#4  WebCore                             000140735485213103 
_ZN7WebCore14DocumentLoader24startLoadingMainResourceEv()
#5  WebCore                             000140735485834990 
_ZN7WebCore11FrameLoader33continueLoadAfterNavigationPolicyERKNS_15ResourceReque
stEN3WTF10PassRefPtrINS_9FormStateEEEb()
#6  WebCore                             000140735485834064 
_ZN7WebCore11FrameLoader37callContinueLoadAfterNavigationPolicyEPvRKNS_15Resourc
eRequestEN3WTF10PassRefPtrINS_9FormStateEEEb()
#7  WebCore                             000140735485833877 
_ZN7WebCore14PolicyCallback4callEb()
#8  WebCore                             000140735485833760 
_ZN7WebCore13PolicyChecker29continueAfterNavigationPolicyENS_12PolicyActionE()
#9  WebKit                              000140735616624699 
-[WebFramePolicyListener receivedPolicyDecision:]
#10 CoreFoundation                      000140735597009900 __invoking___()
#11 CoreFoundation                      000140735597009492 -[NSInvocation 
invoke]
#12 CoreFoundation                      000140735597676006 -[NSInvocation 
invokeWithTarget:]
#13 CoreFoundation                      000140735597478340 ___forwarding___()
#14 CoreFoundation                      000140735597477752 
_CF_forwarding_prep_0()
#15 WebKit                              000140735616622308 
_ZN20WebFrameLoaderClient39dispatchDecidePolicyForNavigationActionEMN7WebCore13P
olicyCheckerEFvNS0_12PolicyActionEERKNS0_16NavigationActionERKNS0_15ResourceRequ
estEN3WTF10PassRefPtrINS0_9FormStateEEE()
. . .

To fix the crash, comment out the -stopLoading line.

Original issue reported on code.google.com by [email protected] on 18 Apr 2014 at 3:20

- (GTMOAuthAuthentication *)myCustomAuth

What steps will reproduce the problem?
1.- (GTMOAuthAuthentication *)myCustomAuth saved this method in AppDelegate 
Class.
2.
3.

What is the expected output? What do you see instead?


What version of the product are you using? On what operating system?


Please provide any additional information below.

Original issue reported on code.google.com by [email protected] on 26 Apr 2012 at 9:00

OAuthSample should be updated for Twitter API 1.1

Here are the changes necessary:

signInToTwitter:
    NSURL *requestURL = [NSURL URLWithString:@"https://api.twitter.com/oauth/request_token"];
    NSURL *accessURL = [NSURL URLWithString:@"https://api.twitter.com/oauth/access_token"];
    NSURL *authorizeURL = [NSURL URLWithString:@"https://api.twitter.com/oauth/authorize"];

doAnAuthenticatedAPIFetch:
    NSString *urlStr = @"https://api.twitter.com/1.1/statuses/home_timeline.json";

Original issue reported on code.google.com by [email protected] on 18 Apr 2014 at 3:25

.- (GTMOAuthAuthentication *)myCustomAuth

What steps will reproduce the problem?
1..- (GTMOAuthAuthentication *)myCustomAuth saved this method in AppDelegate 
Class.
2. GTMOAuthAuthentication *auth = [mainDelegate myCustomAuth]; is used to check 
for authe
3.when I check  if(auth)
    {
        BOOL didAuth = [GTMOAuthViewControllerTouch authorizeFromKeychainForName:@"iphoneapp"  authentication:auth]; 
    }
     and make url call not able to access tokens again 

What is the expected output? What do you see instead?


What version of the product are you using? On what operating system?


Please provide any additional information below.

Original issue reported on code.google.com by [email protected] on 26 Apr 2012 at 9:09

GTMOAuthWindowController language parameter should be used

// this is the designated initializer
- (id)initWithScope:(NSString *)scope
           language:(NSString *)language
    requestTokenURL:(NSURL *)requestURL
  authorizeTokenURL:(NSURL *)authorizeURL
     accessTokenURL:(NSURL *)accessURL
     authentication:(GTMOAuthAuthentication *)auth
     appServiceName:(NSString *)keychainAppServiceName
     resourceBundle:(NSBundle *)bundle;

The language parameter to -initWithScope is dropped on the floor. It should be 
passed along to OAuth if possible. Twitter, for example, would seem to support 
a language parameter:

https://dev.twitter.com/discussions/2741

Original issue reported on code.google.com by [email protected] on 18 Apr 2014 at 3:29

setKeysForResponseString does not properly set the _hasAccessToken flag

What steps will reproduce the problem?
1. Go through normal authorization, and store the persistenceResponseString 
from the GTMOAuthAuthentication object in the keychain.
2. In new attempt at authorization, read back string from keychain and call 
setKeysForReponseString on a new GTMOAuthAuthentication object, then call 
'canAuthorize'.  This will always fail so sign in is required again.

What is the expected output? What do you see instead?
canAuthorize should return YES but returns NO.

What version of the product are you using? On what operating system?
latest trunk of gtm-oauth, in iOS 6.1.3

Please provide any additional information below.
From what I can see, the code in setKeysForResponseDictionary calls 'setToken' 
should be changed to 'setAccessToken' so that the _hasAccessToken gets set to 
YES as well.

Original issue reported on code.google.com by [email protected] on 14 Aug 2013 at 10:35

Signing Out is not really signing out access token is retained...

What steps will reproduce the problem?
1. After being authenticated make a call to  [GTMOAuthViewControllerTouch 
removeParamsFromKeychainForName:kAppServiceName];
2. Create a new instance of GTMOAuthAuthentication *auth and call
- (void)login
{
    if (![self.linkedIn canAuthorize]) {
        self.linkedIn.callback = @"http://www.google.com/OAuthCallback";
        GTMOAuthViewControllerTouch *vc;
        vc = [[[GTMOAuthViewControllerTouch alloc] initWithScope:kAPIScope
                                                        language:nil
                                                 requestTokenURL:[NSURL URLWithString:kRequestTokenURL]
                                               authorizeTokenURL:[NSURL URLWithString:kAuthorizeURL]
                                                  accessTokenURL:[NSURL URLWithString:kAccessTokenURL]
                                                  authentication:self.auth
                                                  appServiceName:kKeyChainKey
                                                        delegate:self
                                                finishedSelector:@selector(viewController:finishedWithAuth:error:)]
              autorelease];
        [[self.appDel nav] pushViewController:vc animated:YES];
    }
}


What is the expected output? What do you see instead?
Expected UIWebView which loads the login screen pushed to navigation stack.
What I see: UIWebView pushed and poped from navigation stack and auth object 
obtaining access token without login

What version of the product are you using? On what operating system?
iOS

Please provide any additional information below.
It seems that auth object is retained within a library with all the associated 
access tokens.
Here is my logout method:

- (void)logout
{
    [GTMOAuthViewControllerTouch removeParamsFromKeychainForName:kKeyChainKey];
    self.auth = nil;
}

Original issue reported on code.google.com by [email protected] on 26 Sep 2012 at 9:30

Dismissing on an error

>>What steps will reproduce the problem?
1. use an invalid Twitter Key
2. push the GTMOAuthViewControllerTouch
3. try to dismiss it when you get the error, it almost never works(have seen it 
work)


>>What is the expected output?
The view should be dismissed


>>What do you see instead?

If I dismiss the view with
            [viewController removeFromParentViewController];
            [viewController viewWillDisappear:YES];
nothing happens and I'm stuck with a white UIWebview most of the time...



>>What version of the product are you using? On what operating system?
iOS


>>Please provide any additional information below.

This seems to actually be a problem with dismissing a view controller with a 
UIWebview.

If I delay the dismiss with a
        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 2 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
            [viewController removeFromParentViewController];
            [viewController viewWillDisappear:YES];
        });
then it works... but this is a crappy way to deal with a race condition in 
someone else's library...

Original issue reported on code.google.com by [email protected] on 16 Jan 2012 at 4:36

oauth_callback parameter not sent with authorize request

What steps will reproduce the problem?
1. Try to authenticate with an OAuth service (not a Google service).
2. Get to the authorize step.
3. The service will not redirect to the oauth_callback specified because it was 
only sent with the request_token request.

What is the expected output? What do you see instead?
According to OAuth 1.0 documentation, you should send the oauth_callback 
parameter with the authorization request. gtm-oauth does not do this.

What version of the product are you using? On what operating system?
Trunk, iOS 4.0

Please provide any additional information below.
See http://oauth.net/core/1.0/#anchor25 for an example of 3 legged 
authentication where oauth_callback is sent as a parameter to step 2 
(authorization).

Original issue reported on code.google.com by [email protected] on 7 Dec 2010 at 7:27

crash in 'Sign Out' from Google.

What steps will reproduce the problem?
1. Select 'Google'.
2. Press 'Sign in..' button.
3. Sign in to Google and authorize contacts.  The contacts should be downloaded.
4. Press 'Sign Out' button.   Crash happens with this message.

Program received signal:  “EXC_BAD_ACCESS”.
(gdb) 

#0  0x026f9918 in objc_msgSend
#1  0x05f33240 in ??
#2  0x004e668b in -[UIBarButtonItem(UIInternal) _sendAction:withEvent:]
#3  0x002da7f8 in -[UIApplication sendAction:to:from:forEvent:]
#4  0x00365de0 in -[UIControl sendAction:to:forEvent:]
#5  0x00368262 in -[UIControl(Internal) _sendActionsForEvents:withEvent:]
#6  0x00366e0f in -[UIControl touchesEnded:withEvent:]
#7  0x002fe3d0 in -[UIWindow _sendTouchesForEvent:]
#8  0x002dfcb4 in -[UIApplication sendEvent:]
#9  0x002e49bf in _UIApplicationHandleEvent
#10 0x02d88822 in PurpleEventCallback
#11 0x0257dff4 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__
#12 0x024de807 in __CFRunLoopDoSource1
#13 0x024dba93 in __CFRunLoopRun
#14 0x024db350 in CFRunLoopRunSpecific
#15 0x024db271 in CFRunLoopRunInMode
#16 0x02d8700c in GSEventRunModal
#17 0x02d870d1 in GSEventRun
#18 0x002e8af2 in UIApplicationMain
#19 0x00002524 in main at mainTouch.m:20


What is the expected output? What do you see instead?

It shoud sign out without crash.

What version of the product are you using? On what operating system?

r24.  iOS 4.1

Please provide any additional information below.

The crash doesn't happen when it connects to Twitter.

Original issue reported on code.google.com by [email protected] on 30 Sep 2010 at 1:48

Deprecated method for iOS 9

GTMOAuth/GTMOAuthAuthentication.m:986:18: 'CFURLCreateStringByAddingPercentEscapes' is deprecated: first deprecated in iOS 9.0 - Use [NSString stringByAddingPercentEncodingWithAllowedCharacters:] instead, which always uses the recommended UTF-8 encoding, and which encodes for a specific URL component or subcomponent (since each URL component or subcomponent has different rules for what characters are valid).

GTMOAuthAuthentication.m:998:29: 'stringByReplacingPercentEscapesUsingEncoding:' is deprecated: first deprecated in iOS 9.0 - Use -stringByRemovingPercentEncoding instead, which always uses the recommended UTF-8 encoding.

GTMOAuthViewControllerTouch.m:249:44: 'applicationFrame' is deprecated: first deprecated in iOS 9.0 - Use -[UIScreen bounds]

GTMOAuthViewControllerTouch.m:616:37: 'shouldAutorotateToInterfaceOrientation:' is deprecated: first deprecated in iOS 6.0

GTMHTTPFetcher.m:381:44: 'initWithRequest:delegate:startImmediately:' is deprecated: first deprecated in iOS 9.0 - Use NSURLSession (see NSURLSession.h)

Sign in gets stuck on google.com/accounts if login session times out

What steps will reproduce the problem?
1. Start the sign-in flow.
2. Enter username and password for an account that uses two-step 
verification/OTP.
3. Leave the app sitting there at the verification code screen for a while 
(until the login session times out).
4. Enter valid verification code/OTP and submit. You'll be redirected back to 
the username/password form.
5. Complete the sign in process successfully.

What is the expected output? What do you see instead?
Expected: either the web view closes or I see the OAuth grant permissions screen
Actual: I see my Google Account page (google.com/accounts)

What version of the product are you using? On what operating system?
r36, iOS 4.2 (8C134) in simulator.

Original issue reported on code.google.com by [email protected] on 28 Mar 2011 at 5:06

GTMOAuthAuthentication breaks when the URL has a port number in it

What steps will reproduce the problem?

  1. Create a GTMOAuthWindowController with a request url:

      "http://localhost:8888/oauth/request"

  2. Bring up the modal sign-in sheet


What is the expected output? What do you see instead?

  You get an error saying host "localhost8888" not found.


What version of the product are you using? On what operating system?

  r25 / OSX


Please provide any additional information below.

  "addParams:toRequest:" omits the ":" when re-assembling the url.
  see attached patch.




Original issue reported on code.google.com by [email protected] on 2 Oct 2010 at 6:24

Attachments:

authorizeRequest falsely requires an accessToken

What steps will reproduce the problem?

1. Create GTMOAuthAuthentication object with signature HMAC_SHA1, consumerKey 
and privateKey.
2. Create NSMutableURLRequest setup to query unauthorised API calls
3. Perform authorizeRequest on GTMOAuthAuthentication object with object from 
step 2.

What is the expected output? What do you see instead?

I expect GTMOAuthAuthentication to add oauth headers:
oauth_consumer_key, oauth_version, oauth_signature_method, oauth_timestamp, 
oauth_nonce and oauth_signature

What version of the product are you using? On what operating system?

Revision r68 from Apr 9, 2013 on Mac OS.

Please provide any additional information below.

Fix is to change current implementation of authorizeRequest:

- (BOOL)authorizeRequest:(NSMutableURLRequest *)request {
  NSString *token = [self token];
  if ([token length] == 0) {
    return NO;
  } else {
    if ([self shouldUseParamsToAuthorize]) {
      [self addResourceTokenParamsToRequest:request];
    } else {
      [self addResourceTokenHeaderToRequest:request];
    }
    return YES;
  }
}

to the following lines:

- (BOOL)authorizeRequest:(NSMutableURLRequest *)request {
//  NSString *token = [self token];
//  if ([token length] == 0) {
//    return NO;
//  } else {
    if ([self shouldUseParamsToAuthorize]) {
      [self addResourceTokenParamsToRequest:request];
    } else {
      [self addResourceTokenHeaderToRequest:request];
    }
    return YES;
//  }
}


Original issue reported on code.google.com by [email protected] on 12 Apr 2013 at 11:35

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.