Skip to content

Commit

Permalink
Fixed a problem when trying to clear the auth data to allow the user …
Browse files Browse the repository at this point in the history
…to re-authorize, or select a different username.
  • Loading branch information
Ben Gottlieb committed Feb 23, 2010
1 parent a2f693a commit 1e5fc10
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
Expand Up @@ -61,6 +61,7 @@ + (BOOL) credentialEntryRequiredWithTwitterEngine: (SA_OAuthTwitterEngine *) eng
- (id) initWithEngine: (SA_OAuthTwitterEngine *) engine andOrientation:(UIInterfaceOrientation)theOrientation {
if (self = [super init]) {
self.engine = engine;
if (!engine.OAuthSetup) [_engine requestRequestToken];
self.orientation = theOrientation;
_firstLoad = YES;

Expand All @@ -76,7 +77,6 @@ - (id) initWithEngine: (SA_OAuthTwitterEngine *) engine andOrientation:(UIInterf
if ([_webView respondsToSelector: @selector(setDataDetectorTypes:)]) [(id) _webView setDataDetectorTypes: 0];

NSURLRequest *request = _engine.authorizeURLRequest;

[_webView loadRequest: request];
}
return self;
Expand Down
2 changes: 1 addition & 1 deletion Twitter+OAuth/SAOAuthTwitterEngine/SA_OAuthTwitterEngine.h 100755 → 100644
Expand Up @@ -40,7 +40,7 @@

@property (nonatomic, readwrite, retain) NSString *consumerSecret, *consumerKey;
@property (nonatomic, readwrite, retain) NSURL *requestTokenURL, *accessTokenURL, *authorizeURL; //you shouldn't need to touch these. Just in case...

@property (nonatomic, readonly) BOOL OAuthSetup;

+ (SA_OAuthTwitterEngine *) OAuthTwitterEngineWithDelegate: (NSObject *) delegate;
- (SA_OAuthTwitterEngine *) initOAuthWithDelegate: (NSObject *) delegate;
Expand Down
13 changes: 10 additions & 3 deletions Twitter+OAuth/SAOAuthTwitterEngine/SA_OAuthTwitterEngine.m 100755 → 100644
Expand Up @@ -70,12 +70,14 @@ - (SA_OAuthTwitterEngine *) initOAuthWithDelegate: (NSObject *) delegate {

//=============================================================================================================================
#pragma mark OAuth Code
- (BOOL) OAuthSetup {
return _consumer != nil;
}
- (OAConsumer *) consumer {
if (_consumer) return _consumer;

NSAssert(self.consumerKey.length > 0 && self.consumerSecret.length > 0, @"You must first set your Consumer Key and Consumer Secret properties. Visit http://twitter.com/oauth_clients/new to obtain these.");
_consumer = [[OAConsumer alloc] initWithKey: self.consumerKey secret: self.consumerSecret];

return _consumer;
}

Expand Down Expand Up @@ -124,14 +126,19 @@ - (void) clearAccessToken {
if ([_delegate respondsToSelector: @selector(storeCachedTwitterOAuthData:forUsername:)]) [(id) _delegate storeCachedTwitterOAuthData: @"" forUsername: self.username];
[_accessToken release];
_accessToken = nil;
[_consumer release];
_consumer = nil;
self.pin = nil;
[_requestToken release];
_requestToken = nil;
}

- (void) setPin: (NSString *) pin {
[_pin autorelease];
_pin = [pin retain];

if (pin.length) _accessToken.pin = pin;
if (pin.length) _requestToken.pin = pin;
_accessToken.pin = pin;
_requestToken.pin = pin;
}

//=============================================================================================================================
Expand Down

0 comments on commit 1e5fc10

Please sign in to comment.