Skip to content

Commit 302c80a

Browse files
committed
Merge branch 'release/1.2.3'
2 parents ab88d96 + dc65777 commit 302c80a

File tree

9 files changed

+44
-8
lines changed

9 files changed

+44
-8
lines changed

NXOAuth2Client.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'NXOAuth2Client'
3-
s.version = '1.2.2'
3+
s.version = '1.2.3'
44
s.license = {
55
:type => 'BSD',
66
:text => <<-LICENSETEXT

OAuth2Client.framework-Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<key>CFBundlePackageType</key>
1414
<string>FMWK</string>
1515
<key>CFBundleShortVersionString</key>
16-
<string>1.2.0</string>
16+
<string>1.2.3</string>
1717
<key>CFBundleSignature</key>
1818
<string>????</string>
1919
<key>CFBundleVersion</key>

OAuth2Client.xcodeproj/project.pbxproj

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@
362362
0867D690FE84028FC02AAC07 /* Project object */ = {
363363
isa = PBXProject;
364364
attributes = {
365-
LastUpgradeCheck = 0450;
365+
LastUpgradeCheck = 0460;
366366
ORGANIZATIONNAME = nxtbgthng;
367367
};
368368
buildConfigurationList = 1DEB922208733DC00010E9CD /* Build configuration list for PBXProject "OAuth2Client" */;
@@ -447,7 +447,6 @@
447447
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
448448
CLANG_ENABLE_OBJC_ARC = YES;
449449
COPY_PHASE_STRIP = NO;
450-
DEPLOYMENT_LOCATION = YES;
451450
DSTROOT = /tmp/OAuth2Client.dst;
452451
GCC_DYNAMIC_NO_PIC = NO;
453452
GCC_MODEL_TUNING = G5;
@@ -470,7 +469,6 @@
470469
ALWAYS_SEARCH_USER_PATHS = NO;
471470
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
472471
CLANG_ENABLE_OBJC_ARC = YES;
473-
DEPLOYMENT_LOCATION = YES;
474472
DSTROOT = /tmp/OAuth2Client.dst;
475473
GCC_MODEL_TUNING = G5;
476474
GCC_PRECOMPILE_PREFIX_HEADER = YES;
@@ -489,7 +487,6 @@
489487
isa = XCBuildConfiguration;
490488
buildSettings = {
491489
ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
492-
COMBINE_HIDPI_IMAGES = YES;
493490
GCC_C_LANGUAGE_STANDARD = c99;
494491
GCC_OPTIMIZATION_LEVEL = 0;
495492
GCC_WARN_ABOUT_RETURN_TYPE = YES;
@@ -503,7 +500,6 @@
503500
isa = XCBuildConfiguration;
504501
buildSettings = {
505502
ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
506-
COMBINE_HIDPI_IMAGES = YES;
507503
GCC_C_LANGUAGE_STANDARD = c99;
508504
GCC_WARN_ABOUT_RETURN_TYPE = YES;
509505
GCC_WARN_UNUSED_VARIABLE = YES;

Sources/OAuth2Client/NXOAuth2AccessToken.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ + (id)tokenWithResponseBody:(NSString *)theResponseBody tokenType:(NSString *)to
6767
}
6868

6969
NSDate *expiryDate = nil;
70-
if (expiresIn) {
70+
if (expiresIn != nil && expiresIn != [NSNull null]) {
7171
expiryDate = [NSDate dateWithTimeIntervalSinceNow:[expiresIn integerValue]];
7272
}
7373
return [[[self class] alloc] initWithAccessToken:anAccessToken

Sources/OAuth2Client/NXOAuth2AccountStore.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ typedef void(^NXOAuth2PreparedAuthorizationURLHandler)(NSURL *preparedURL);
123123
- (void)requestAccessToAccountWithType:(NSString *)accountType withPreparedAuthorizationURLHandler:(NXOAuth2PreparedAuthorizationURLHandler)aPreparedAuthorizationURLHandler;
124124
- (void)requestAccessToAccountWithType:(NSString *)accountType username:(NSString *)username password:(NSString *)password;
125125
- (void)requestAccessToAccountWithType:(NSString *)accountType assertionType:(NSURL *)assertionType assertion:(NSString *)assertion;
126+
- (void)requestClientCredentialsAccessWithType:(NSString *)accountType;
126127
- (void)removeAccount:(NXOAuth2Account *)account;
127128

128129

Sources/OAuth2Client/NXOAuth2AccountStore.m

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,12 @@ - (void)requestAccessToAccountWithType:(NSString *)accountType assertionType:(NS
205205
[client authenticateWithAssertionType:assertionType assertion:assertion];
206206
}
207207

208+
- (void)requestClientCredentialsAccessWithType:(NSString *)accountType;
209+
{
210+
NXOAuth2Client *client = [self pendingOAuthClientForAccountType:accountType];
211+
[client authenticateWithClientCredentials];
212+
}
213+
208214
- (void)removeAccount:(NXOAuth2Account *)account;
209215
{
210216
if (account) {

Sources/OAuth2Client/NXOAuth2Client.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ extern NSString * const NXOAuth2ClientConnectionContextTokenRefresh;
6767

6868
@property (nonatomic, copy) NSSet *desiredScope;
6969
@property (nonatomic, copy) NSString *userAgent;
70+
@property (nonatomic, copy) NSString *acceptType; // defaults to application/json
7071

7172
@property (nonatomic, strong) NXOAuth2AccessToken *accessToken;
7273
@property (nonatomic, unsafe_unretained) NSObject<NXOAuth2ClientDelegate>* delegate;
@@ -122,6 +123,7 @@ extern NSString * const NXOAuth2ClientConnectionContextTokenRefresh;
122123
/*!
123124
* Authenticate with username & password (User Credentials Flow)
124125
*/
126+
- (void)authenticateWithClientCredentials;
125127
- (void)authenticateWithUsername:(NSString *)username password:(NSString *)password;
126128

127129
/*!

Sources/OAuth2Client/NXOAuth2Client.m

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ - (id)initWithClientID:(NSString *)aClientId
9191
tokenType = [aTokenType copy];
9292
accessToken = anAccessToken;
9393

94+
self.acceptType = @"application/json";
95+
9496
self.persistent = shouldPersist;
9597
self.delegate = aDelegate;
9698
}
@@ -333,6 +335,31 @@ - (void)requestTokenWithAuthGrant:(NSString *)authGrant redirectURL:(NSURL *)red
333335
authConnection.context = NXOAuth2ClientConnectionContextTokenRequest;
334336
}
335337

338+
// Client Credential Flow
339+
- (void)authenticateWithClientCredentials;
340+
{
341+
NSAssert1(!authConnection, @"authConnection already running with: %@", authConnection);
342+
343+
NSMutableURLRequest *tokenRequest = [NSMutableURLRequest requestWithURL:tokenURL];
344+
[tokenRequest setHTTPMethod:@"POST"];
345+
[authConnection cancel]; // just to be sure
346+
347+
self.authenticating = YES;
348+
349+
NSMutableDictionary *parameters = [NSMutableDictionary dictionaryWithObjectsAndKeys:
350+
@"client_credentials", @"grant_type",
351+
clientId, @"client_id",
352+
clientSecret, @"client_secret",
353+
nil];
354+
if (self.desiredScope) {
355+
[parameters setObject:[[self.desiredScope allObjects] componentsJoinedByString:@" "] forKey:@"scope"];
356+
}
357+
authConnection = [[NXOAuth2Connection alloc] initWithRequest:tokenRequest
358+
requestParameters:parameters
359+
oauthClient:self
360+
delegate:self];
361+
authConnection.context = NXOAuth2ClientConnectionContextTokenRequest;
362+
}
336363

337364
// User Password Flow Only
338365
- (void)authenticateWithUsername:(NSString *)username password:(NSString *)password;

Sources/OAuth2Client/NXOAuth2Connection.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,10 @@ - (NSURLConnection *)createConnection;
197197
[startRequest setValue:client.userAgent forHTTPHeaderField:@"User-Agent"];
198198
}
199199

200+
if (client.acceptType) {
201+
[startRequest setValue:client.acceptType forHTTPHeaderField:@"Accept"];
202+
}
203+
200204
NSURLConnection *aConnection = [[NSURLConnection alloc] initWithRequest:startRequest delegate:self startImmediately:NO]; // don't start yet
201205
[aConnection scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; // let's first schedule it in the current runloop. (see http://github.com/soundcloud/cocoa-api-wrapper/issues#issue/2 )
202206
[aConnection start]; // now start

0 commit comments

Comments
 (0)