Skip to content

Commit 2d475ea

Browse files
committed
Squashed commit of the following:
commit 1e899ee Author: Hamilton <[email protected]> Date: Fri Jul 17 23:49:43 2020 -0700 Chill some warnings CFURLCreateStringByAddingPercentEscapes -> stringByAddingPercentEncodingWithAllowedCharacters. commit 53e3108 Author: Hamilton <[email protected]> Date: Tue Jul 14 18:11:02 2020 -0700 Xcode 12 updates commit b7b32b8 Author: Hamilton Feltman <[email protected]> Date: Sat Nov 2 21:05:11 2019 -0700 Some nonsense commit 2a063e1 Author: pwnified <[email protected]> Date: Fri Apr 12 21:51:55 2019 -0700 Removed TODO comments because they conflict with the todo system commit 4abe954 Merge: cdb9f12 c46e949 Author: pwnified <[email protected]> Date: Fri Apr 12 21:47:19 2019 -0700 Merge branch 'master' of https://github.com/pwnified/OAuth2Client into master2 * 'master' of https://github.com/pwnified/OAuth2Client: Localizations update Silence warning about Base localization. Xcode noise Xocde noise Xcode 8 and iOS 10 updates. Not sure what this bullshit is this time # Conflicts: # OAuth2Client.xcodeproj/project.pbxproj commit cdb9f12 Author: pwnified <[email protected]> Date: Mon Apr 1 13:12:24 2019 -0700 iOS deployment target from 5.1 to 8.0 commit c46e949 Author: Hamilton Feltman <[email protected]> Date: Fri Mar 29 20:31:16 2019 -0700 Localizations update commit 37543a4 Author: pwnified <[email protected]> Date: Fri Sep 21 14:06:20 2018 -0700 Silence warning about Base localization. commit ef77c3d Author: pwnified <[email protected]> Date: Tue May 15 22:19:22 2018 -0700 Xcode noise commit 7cc9bf5 Author: pwnified <[email protected]> Date: Wed Nov 1 15:12:28 2017 -0700 Xocde noise commit 4325096 Author: pwnified <[email protected]> Date: Tue Oct 11 21:12:50 2016 -0700 Xcode 8 and iOS 10 updates. commit da855c0 Author: hamilton <[email protected]> Date: Wed Mar 30 00:53:36 2016 -0700 Not sure what this bullshit is this time commit 2eaa69d Author: hamilton <[email protected]> Date: Wed Oct 21 21:51:21 2015 -0700 Every time. commit d3597b8 Author: hamilton <[email protected]> Date: Sun Oct 4 17:04:32 2015 -0700 Compiler warning from last submit on armv7. commit 7228a5d Author: hamilton <[email protected]> Date: Sun Oct 4 16:13:37 2015 -0700 Allow printing of negative OSStatus error codes. commit 0584245 Merge: abc5262 4a71e8a Author: hamilton <[email protected]> Date: Thu Oct 1 20:30:53 2015 -0700 Merge branch 'develop' of https://github.com/nxtbgthng/OAuth2Client Conflicts: Sources/OAuth2Client/NXOAuth2AccountStore.m Sources/OAuth2Client/NXOAuth2PostBodyStream.m commit 4a71e8a Merge: 685e54c 12241ed Author: Thomas Kollbach <[email protected]> Date: Wed Sep 2 18:16:37 2015 +0200 Merge pull request nxtbgthng#192 from zittix/patch-1 Fix non-standard invalid_token header detection commit abc5262 Author: hamilton <[email protected]> Date: Fri Aug 21 21:01:30 2015 +0900 Xcode noise. Removed armv7s arch. Null check on 'foundAccount'. commit 12241ed Author: Mathieu Monney <[email protected]> Date: Thu Aug 20 10:03:23 2015 +0200 Added invalid_token detection to be backward compatible commit da014b1 Author: Mathieu Monney <[email protected]> Date: Thu Aug 20 09:02:24 2015 +0200 Fix non-standard invalid_token header detection This PR fixes a problem where the header of Www-authenticate was checked with a non-standard keywork for invalid token. Per the RFC, the standard keyword **invalid_grant** specify an invalid or expired token. Moreover it has been added a check to try to refresh the token if possible. commit 685e54c Merge: b848013 6880eb7 Author: Thomas Kollbach <[email protected]> Date: Sat Jul 11 14:43:15 2015 +0200 Merge pull request nxtbgthng#189 from progrmr/feature/fixCompilerWarnings fixed implicit conversion warnings commit 6880eb7 Author: Gary A. Morris <[email protected]> Date: Sat Jul 11 05:14:22 2015 -0700 fixed implicit conversion warnings on 64-bit devices, used matching types commit b848013 Merge: 893bcd1 17a05f0 Author: Thomas Kollbach <[email protected]> Date: Tue Jun 23 14:28:55 2015 +0200 Merge pull request nxtbgthng#186 from orkoden/feature/error_param_for_redirecturl Add error parameter for handling redirect URLs commit 17a05f0 Author: Jörg Bühmann <[email protected]> Date: Mon Jun 22 22:46:49 2015 +0200 Adds hint to use custom url scheme with external browser Also emphasizes on which object to call the method for handling the redirect URL. commit a5c3653 Author: Jörg Bühmann <[email protected]> Date: Mon Jun 22 22:30:22 2015 +0200 adds NSError** parameter to handling of redirect URL Methods returning a BOOL should return an NSError if one is created inside of it. https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/ErrorHandlingCocoa/CreateCustomizeNSError/CreateCustomizeNSError.html#//apple_ref/doc/uid/TP40001806-CH204-BAJIIGCC commit 012676f Author: Jörg Bühmann <[email protected]> Date: Mon Jun 22 21:46:46 2015 +0200 avoids crash with nil as value in dictionary commit f279e13 Author: hamilton <[email protected]> Date: Wed Jun 17 22:16:21 2015 -0700 armv7s commit b4aa4dd Merge: 6ada63b 893bcd1 Author: hamilton <[email protected]> Date: Wed Jun 17 17:28:13 2015 -0700 Merge commit '893bcd1ad9b85d81291f428df0534405a0e7c920' Conflicts: OAuth2Client.xcodeproj/project.pbxproj commit 893bcd1 Merge: 8a8f30d 2d68048 Author: Thomas Kollbach <[email protected]> Date: Fri Jun 12 14:53:02 2015 +0200 Merge pull request nxtbgthng#184 from anagromataf/feature/request-access Automatically Request Access for Connections commit 2d68048 Author: Tobias Kräntzer <[email protected]> Date: Thu May 21 17:06:44 2015 +0200 Check if the connection is the auth connection of the client (and if yes, do not trigger an auth if the response is a 401) commit afdb8d2 Author: Tobias Kräntzer <[email protected]> Date: Thu May 21 15:05:12 2015 +0200 Request access if a connection receives a 401 and has a oauth client without an access token. commit 8a8f30d Merge: cde9332 176fd3d Author: Thomas Kollbach <[email protected]> Date: Mon Apr 27 17:31:08 2015 +0200 Merge pull request nxtbgthng#170 from sirnacnud/shared-keychain Added support for keychain access group under iOS commit cde9332 Merge: ae85fb3 2fb1f9e Author: Thomas Kollbach <[email protected]> Date: Mon Apr 27 15:04:26 2015 +0200 Merge pull request nxtbgthng#164 from tomhoag/docRemoveCookies Added instructions for removing account and cookies that may be in NSHTTPCookieStorage commit ae85fb3 Merge: 269536f ef7718f Author: Thomas Kollbach <[email protected]> Date: Fri Apr 24 23:14:42 2015 +0200 Merge pull request nxtbgthng#172 from wireframe/refresh-fix-compilation Fix compilation error for NXOAuth2AccountStore accessToken property commit ef7718f Author: Ryan Sonnek <[email protected]> Date: Fri Apr 24 12:15:21 2015 -0500 cherry-pick d78dd61 commit 269536f Merge: 5fe6147 b5ebf00 Author: Thomas Kollbach <[email protected]> Date: Fri Apr 24 17:23:53 2015 +0200 Merge pull request nxtbgthng#171 from wireframe/refresh-fix [refresh] Updating access token and posting notification on token refresh commit b5ebf00 Author: Aleksandr Dodatko <[email protected]> Date: Fri Apr 10 17:56:32 2015 +0300 [refresh] Updating access token and posting notification on token refresh commit 176fd3d Author: sir_nacnud <[email protected]> Date: Wed Apr 22 23:22:59 2015 -0500 Undo changes to comments about keychain commit 8c28724 Author: sir_nacnud <[email protected]> Date: Wed Apr 22 23:13:15 2015 -0500 Modified OS X keychain functions to match iOS keychain functions commit 3cfadfb Merge: aac0ed6 5fe6147 Author: sir_nacnud <[email protected]> Date: Wed Apr 22 14:32:53 2015 -0500 Merge remote-tracking branch 'origin/develop' into shared-keychain commit 5fe6147 Author: Thomas Kollbach <[email protected]> Date: Sat Apr 18 14:13:40 2015 +0200 fix accidental merge commit aac0ed6 Merge: f7f7945 e56827b Author: sir_nacnud <[email protected]> Date: Thu Apr 16 02:38:16 2015 -0500 Merge remote-tracking branch 'origin/develop' into shared-keychain commit e56827b Merge: d1b9eda 5a55e90 Author: Thomas Kollbach <[email protected]> Date: Thu Apr 16 09:31:32 2015 +0200 Merge pull request nxtbgthng#161 from linitix/develop Add guard to unsupported features of iOS 8 extensions commit f7f7945 Author: sir_nacnud <[email protected]> Date: Wed Apr 15 22:57:39 2015 -0500 Disabled keychain access group for iOS Simulator commit 6ada63b Author: pwnified <[email protected]> Date: Thu Apr 9 22:11:19 2015 -0700 apple bullshit commit d9825da Author: sir_nacnud <[email protected]> Date: Sun Apr 5 19:08:54 2015 -0500 Added support to specify the keychain access group for iOS commit 5a55e90 Author: Damien Rambout <[email protected]> Date: Fri Apr 3 12:24:55 2015 +0200 Rename NX_APP_EXTENSION guard macro into NX_APP_EXTENSIONS commit 2fb1f9e Author: Tom <[email protected]> Date: Thu Apr 2 11:07:05 2015 -0400 added instructions for removing account and cookies that may be in NSHTTPCookieStorage' commit 6e39657 Author: Damien Rambout <[email protected]> Date: Sun Mar 29 22:44:00 2015 +0200 Add guard to unsupported features of iOS 8 extensions commit e971c2e Author: pwnified <[email protected]> Date: Fri Mar 13 14:17:57 2015 -0700 Xcode LastUpgradeCheck noise. commit d1b9eda Merge: 378a720 7d22d0d Author: Thomas Kollbach <[email protected]> Date: Fri Mar 13 22:17:16 2015 +0100 Merge pull request nxtbgthng#160 from tomhoag/readmeAdditions README.md -- Added additional instruction and code examples commit 7d22d0d Author: Tom <[email protected]> Date: Fri Mar 13 17:08:47 2015 -0400 Added addition instruction and code examples for configuring for Content-Type:application/x-www-form-urlencoded, using a UIWebView and calling handleRedirectURL: commit 378a720 Merge: 9dd5a3f 395200d Author: Thomas Kollbach <[email protected]> Date: Tue Mar 10 18:33:02 2015 +0100 Merge pull request nxtbgthng#158 from tomhoag/issue156 Issue156: Fixed NSAsserts to catch the right condition. (Removed the ba... commit 395200d Author: Tom <[email protected]> Date: Tue Mar 10 13:20:05 2015 -0400 Issue156: Fixed NSAsserts to catch the right condition. (Removed the bang) commit 9dd5a3f Merge: cf4d87f f84a8cf Author: Thomas Kollbach <[email protected]> Date: Tue Mar 10 14:26:20 2015 +0100 Merge pull request nxtbgthng#157 from tomhoag/issue156 Issue156: Added NSAssert to setClient: methods to check for nil values in keyChain... commit f84a8cf Author: Tom <[email protected]> Date: Tue Mar 10 09:08:42 2015 -0400 Added NSAssert to setClient: methods to check for nil values in keyChainGroup and tokenType commit 429648f Author: pwnified <[email protected]> Date: Sat Feb 28 01:29:34 2015 -0800 add armv7s commit e91b529 Author: pwnified <[email protected]> Date: Thu Jan 29 00:01:14 2015 -0800 bs commit 86a68b9 Merge: 6b53167 6d98d0b Author: pwnified <[email protected]> Date: Tue Jan 27 03:39:58 2015 -0800 Merge branch 'master' of git://github.com/nxtbgthng/OAuth2Client Conflicts: OAuth2Client.xcodeproj/project.pbxproj Sources/OAuth2Client/NXOAuth2AccessToken.m Sources/OAuth2Client/NXOAuth2AccountStore.m commit 6d98d0b Merge: 8a52237 a3ac417 Author: Thomas Kollbach <[email protected]> Date: Wed Oct 8 11:01:26 2014 +0200 Merge branch 'release/1.2.8' commit 6b53167 Merge: 28becdf 8a52237 Author: pwnified <[email protected]> Date: Mon Sep 8 07:50:32 2014 -0700 Merge branch 'master' of git://github.com/nxtbgthng/OAuth2Client commit 28becdf Author: pwnified <[email protected]> Date: Mon Sep 8 07:50:18 2014 -0700 shitpile commit 8a52237 Merge: 17342b9 bb9e288 Author: Thomas Kollbach <[email protected]> Date: Thu Jun 12 23:19:25 2014 +0200 Merge branch 'develop' commit 17342b9 Merge: c31338f 32bc250 Author: Thomas Kollbach <[email protected]> Date: Thu Jun 12 17:25:19 2014 +0200 Merge branch 'release/1.2.6' commit cb77ce6 Merge: 431d79e c31338f Author: pwnified <[email protected]> Date: Tue Jan 14 14:03:51 2014 -0800 Merge branch 'master' of git://github.com/nxtbgthng/OAuth2Client commit 431d79e Author: pwnified <[email protected]> Date: Sat Nov 23 22:26:00 2013 -0800 64 BIT SUPPORT commit d6ad516 Merge: de23670 5af42be Author: pwnified <[email protected]> Date: Sat Aug 3 21:39:39 2013 +0900 Merge branch 'master' of git://github.com/nxtbgthng/OAuth2Client commit de23670 Merge: 073e117 190223f Author: pwnified <[email protected]> Date: Wed Jul 3 19:27:36 2013 -0700 errr commit 073e117 Merge: 4b58a61 bcd8adb Author: pwnified <[email protected]> Date: Fri Nov 2 19:47:33 2012 -0700 pos commit 4b58a61 Author: pwnified <[email protected]> Date: Fri Nov 2 19:42:06 2012 -0700 pos commit d5e46e5 Merge: b0850ec 5b4a4c3 Author: pwnified <[email protected]> Date: Sat Oct 6 05:43:16 2012 -0700 Merge branch 'master' of git://github.com/nxtbgthng/OAuth2Client commit b0850ec Author: pwnified <[email protected]> Date: Sat Sep 29 21:29:10 2012 -0700 Project Updates
1 parent 1d8d071 commit 2d475ea

16 files changed

+470
-199
lines changed

NXOAuth2Account+Private.h

+2
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,6 @@
2121
- (instancetype)initAccountWithAccessToken:(NXOAuth2AccessToken *)accessToken
2222
accountType:(NSString *)accountType;
2323

24+
@property (nonatomic, strong) NXOAuth2AccessToken *accessToken;
25+
2426
@end

OAuth2Client.xcodeproj/project.pbxproj

+23-10
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@
8181

8282
/* Begin PBXFileReference section */
8383
824D5A6D123F68A8001177D5 /* NXOAuth2ClientDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NXOAuth2ClientDelegate.h; sourceTree = "<group>"; };
84-
83DD991B6049465CB61E135B /* Pods-OAuth2ClientTests.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-OAuth2ClientTests.xcconfig"; path = "Pods/Pods-OAuth2ClientTests.xcconfig"; sourceTree = "<group>"; };
8584
9404FAC1123E3A6900397DD1 /* NXOAuth2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NXOAuth2.h; sourceTree = "<group>"; };
8685
9429B3A812267A3100D31807 /* NXOAuth2Client.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NXOAuth2Client.h; sourceTree = "<group>"; };
8786
9429B3A912267A3100D31807 /* NXOAuth2Client.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NXOAuth2Client.m; sourceTree = "<group>"; };
@@ -111,9 +110,11 @@
111110
99D8A7F713852C6E00E3073C /* NSData+NXOAuth2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSData+NXOAuth2.h"; sourceTree = "<group>"; };
112111
99D8A7FE13852D3600E3073C /* NSData+NXOAuth2.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSData+NXOAuth2.m"; sourceTree = "<group>"; };
113112
99F08DE9138BE8CE002A5401 /* NXOAuth2TrustDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NXOAuth2TrustDelegate.h; sourceTree = "<group>"; };
113+
A584AA53216FADEE87202521 /* Pods-OAuth2ClientTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-OAuth2ClientTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-OAuth2ClientTests/Pods-OAuth2ClientTests.release.xcconfig"; sourceTree = "<group>"; };
114114
AA747D9E0F9514B9006C5449 /* OAuth2Client_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OAuth2Client_Prefix.pch; sourceTree = "<group>"; };
115115
AACBBE490F95108600F1A2B1 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
116116
B9E2089E9E7941B7AF3D27AA /* libPods-OAuth2ClientTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-OAuth2ClientTests.a"; sourceTree = BUILT_PRODUCTS_DIR; };
117+
CCCB476CC96A52415E9D44D3 /* Pods-OAuth2ClientTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-OAuth2ClientTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-OAuth2ClientTests/Pods-OAuth2ClientTests.debug.xcconfig"; sourceTree = "<group>"; };
117118
D2AAC07E0554694100DB518D /* libOAuth2Client.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libOAuth2Client.a; sourceTree = BUILT_PRODUCTS_DIR; };
118119
F6525B4313D593C900ACAE8F /* NXOAuth2Account+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NXOAuth2Account+Private.h"; sourceTree = SOURCE_ROOT; };
119120
F65713CC13CC87FD00C8A33A /* NXOAuth2AccountStore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NXOAuth2AccountStore.h; sourceTree = "<group>"; };
@@ -167,7 +168,7 @@
167168
0867D69AFE84028FC02AAC07 /* Frameworks */,
168169
034768DFFF38A50411DB9C8B /* Products */,
169170
942FFCDE12315E2E00E6C65E /* Resources */,
170-
83DD991B6049465CB61E135B /* Pods-OAuth2ClientTests.xcconfig */,
171+
B061851D30896FF145B69FB5 /* Pods */,
171172
);
172173
name = OAuth2Client;
173174
sourceTree = "<group>";
@@ -261,6 +262,15 @@
261262
path = Tests;
262263
sourceTree = "<group>";
263264
};
265+
B061851D30896FF145B69FB5 /* Pods */ = {
266+
isa = PBXGroup;
267+
children = (
268+
CCCB476CC96A52415E9D44D3 /* Pods-OAuth2ClientTests.debug.xcconfig */,
269+
A584AA53216FADEE87202521 /* Pods-OAuth2ClientTests.release.xcconfig */,
270+
);
271+
name = Pods;
272+
sourceTree = "<group>";
273+
};
264274
F6E1A11313D7128100B6DAC3 /* Private */ = {
265275
isa = PBXGroup;
266276
children = (
@@ -380,18 +390,19 @@
380390
0867D690FE84028FC02AAC07 /* Project object */ = {
381391
isa = PBXProject;
382392
attributes = {
383-
LastUpgradeCheck = 1110;
393+
LastUpgradeCheck = 1200;
384394
ORGANIZATIONNAME = nxtbgthng;
385395
};
386396
buildConfigurationList = 1DEB922208733DC00010E9CD /* Build configuration list for PBXProject "OAuth2Client" */;
387397
compatibilityVersion = "Xcode 3.2";
388-
developmentRegion = English;
398+
developmentRegion = en;
389399
hasScannedForEncodings = 1;
390400
knownRegions = (
391-
English,
392-
Japanese,
393-
French,
394-
German,
401+
Base,
402+
ja,
403+
de,
404+
fr,
405+
en,
395406
);
396407
mainGroup = 0867D691FE84028FC02AAC07 /* OAuth2Client */;
397408
productRefGroup = 034768DFFF38A50411DB9C8B /* Products */;
@@ -473,7 +484,6 @@
473484
GCC_THUMB_SUPPORT = NO;
474485
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
475486
INSTALL_PATH = /usr/local/lib;
476-
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
477487
PRODUCT_NAME = OAuth2Client;
478488
SDKROOT = iphoneos;
479489
SKIP_INSTALL = YES;
@@ -492,7 +502,6 @@
492502
GCC_THUMB_SUPPORT = NO;
493503
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
494504
INSTALL_PATH = /usr/local/lib;
495-
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
496505
PRODUCT_NAME = OAuth2Client;
497506
SDKROOT = iphoneos;
498507
SKIP_INSTALL = YES;
@@ -515,6 +524,7 @@
515524
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
516525
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
517526
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
527+
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
518528
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
519529
CLANG_WARN_STRICT_PROTOTYPES = YES;
520530
CLANG_WARN_SUSPICIOUS_MOVE = YES;
@@ -531,6 +541,7 @@
531541
GCC_WARN_UNINITIALIZED_AUTOS = YES;
532542
GCC_WARN_UNUSED_FUNCTION = YES;
533543
GCC_WARN_UNUSED_VARIABLE = YES;
544+
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
534545
MACOSX_DEPLOYMENT_TARGET = 10.7;
535546
ONLY_ACTIVE_ARCH = YES;
536547
OTHER_LDFLAGS = "-ObjC";
@@ -553,6 +564,7 @@
553564
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
554565
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
555566
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
567+
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
556568
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
557569
CLANG_WARN_STRICT_PROTOTYPES = YES;
558570
CLANG_WARN_SUSPICIOUS_MOVE = YES;
@@ -567,6 +579,7 @@
567579
GCC_WARN_UNINITIALIZED_AUTOS = YES;
568580
GCC_WARN_UNUSED_FUNCTION = YES;
569581
GCC_WARN_UNUSED_VARIABLE = YES;
582+
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
570583
MACOSX_DEPLOYMENT_TARGET = 10.7;
571584
OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
572585
OTHER_LDFLAGS = "-ObjC";

Podfile.lock

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ PODS:
22
- Expecta (0.3.1)
33
- OCMock (3.1.1)
44
- OHHTTPStubs (3.1.5):
5-
- OHHTTPStubs/Core
5+
- OHHTTPStubs/Core (= 3.1.5)
66
- OHHTTPStubs/Core (3.1.5)
77
- Specta (0.2.1)
88

@@ -18,4 +18,4 @@ SPEC CHECKSUMS:
1818
OHHTTPStubs: c1e362552b71b81e1deb7a80f44c51585b946c43
1919
Specta: 9141310f46b1f68b676650ff2854e1ed0b74163a
2020

21-
COCOAPODS: 0.33.1
21+
COCOAPODS: 0.36.1

README.md

+60-1
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,19 @@ The best place to configure your client is `+[UIApplicationDelegate initialize]`
8080

8181
Take a look at the [Wiki](https://github.com/nxtbgthng/OAuth2Client/wiki) for some examples.
8282

83+
Unless otherwise specficied, the token request will be called with a HTTP Header 'Content-Type' set to 'multipart/form-data'. If you wish that header to be set to 'application/x-www-form-urlencoded', the custom header fields must be modified.
84+
85+
<pre>
86+
NSMutableDictionary *configuration = [NSMutableDictionary dictionaryWithDictionary:[[NXOAuth2AccountStore sharedStore] configurationForAccountType:kOAuth2AccountType]];
87+
NSDictionary *customHeaderFields = [NSDictionary dictionaryWithObject:@"application/x-www-form-urlencoded" forKey:@"Content-Type"];
88+
[configuration setObject:customHeaderFields forKey:kNXOAuth2AccountStoreConfigurationCustomHeaderFields];
89+
[[NXOAuth2AccountStore sharedStore] setConfiguration:configuration forAccountType:kOAuth2AccountType];
90+
</pre>
91+
92+
Consult the documentation of the OAuth2 provider to determine acceptable Content-Type header values.
93+
94+
95+
8396
### Requesting Access to a Service
8497

8598
Once you have configured your client you are ready to request access to one of those services. The NXOAuth2AccountStore provides three different methods for this:
@@ -96,7 +109,12 @@ Once you have configured your client you are ready to request access to one of t
96109
[[NXOAuth2AccountStore sharedStore] requestAccessToAccountWithType:@"myFancyService"];
97110
</pre>
98111

99-
If you are using an external browser, your application needs to handle the URL you have registered as an redirect URL for the account type. The service will redirect to that URL after the authentication process.
112+
If you are using an external browser, your application needs to handle the URL you have registered as an redirect URL for the account type (e.g. a custom URL scheme like `myfancyscheme://oauth`). The service will redirect to that URL after the authentication process.
113+
114+
In `-[AppDelegate application: openURL: sourceApplication: annotation:]` pass the redirect URL to
115+
<pre>
116+
[[NXOAuth2AccountStore sharedStore] handleRedirectURL: url];
117+
</pre>
100118

101119
- Provide an Authorization URL Handler
102120
<pre>
@@ -106,6 +124,24 @@ Once you have configured your client you are ready to request access to one of t
106124
}];
107125
</pre>
108126
Using an authorization URL handler gives you the ability to open the URL in an own web view or do some fancy stuff for authentication. Therefore you pass a block to the NXOAuth2AccountStore while requesting access.
127+
128+
One method for receiving a code and exchanging it for an auth token requires the following:
129+
130+
1) Load the preparedURL into an existing UIWebView as part of the block code above. Be certain to set the delegate for the UIWebView.
131+
132+
<pre>
133+
[_webView loadRequest:[NSURLRequest requestWithURL:preparedURL]];
134+
</pre>
135+
136+
2) In the `webViewDidFinishLoad:` delegate method, you will need to parse the URL for your callback URL. If there is a match, pass that URL to `-[NXOAuth2AccountStore handleRedirectURL:]`
137+
138+
<pre>
139+
if ([webView.request.URL.absoluteString rangeOfString:kOAuth2RedirectURL options:NSCaseInsensitiveSearch].location != NSNotFound) {
140+
[[NXOAuth2AccountStore sharedStore] handleRedirectURL:[NSURL URLWithString:webView.request.URL.absoluteString]];
141+
}
142+
</pre>
143+
144+
This is a very basic example. In the above, it is assumed that the `code` being returned from the OAuth2 provider is in the query parameter of the webView.request.URL (i.e. `http://myredirecturl.com?code=<verylongcodestring>`). This is not always the case and you may have to look elsewhere for the code (e.g. in the page content, web page title). You must prepare a URL in the format described above to pass to `-[NXOAuth2AccountStore handleRedirectURL:]`.
109145

110146
#### On Success
111147

@@ -159,6 +195,29 @@ account.userData = userData;
159195

160196
This payload will be stored together with the accounts in the Keychain. Thus it shouldn't be too big.
161197

198+
### Removing Accounts
199+
200+
To remove an account and its tokens from the store:
201+
202+
<pre>
203+
[[NXOAuth2AccountStore sharedStore] removeAccount:account];
204+
</pre>
205+
206+
Note that if you used a UIWebView to request access to a service as described above, it's likely that the token has been cached in `[NSHTTPCookieStorage sharedHTTPCookieStorage]`
207+
208+
You can remove the auth token from the cookie cache using:
209+
210+
<pre>
211+
for(NSHTTPCookie *cookie in [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookies]) {
212+
if([[cookie domain] isEqualToString:@"myapp.com"]) {
213+
[[NSHTTPCookieStorage sharedHTTPCookieStorage] deleteCookie:cookie];
214+
}
215+
}
216+
[[NSUserDefaults standardUserDefaults] synchronize];
217+
</pre>
218+
219+
Where `myapp.com` is the domain from which you received the auth token -- likley the `authorizationURL` assigned to the store at the time of request. As a convenience, you may want to store the domain of the token in the `account.userData` so that it is readily available if you need to delete the cookies.
220+
162221
### Invoking a Request
163222

164223
A request using the authentication for a service can be invoked via `NXOAuth2Request`. The most convenient method (see below) is a class method which you pass the method, a resource and some parameters (or nil) for the request and to handlers (both optional). One for a progress and the other for the response. The account is used for authentication and can be nil. Then a normal request without authentication will be invoked.

Sources/NSString+NXOAuth2.m

+13-9
Original file line numberDiff line numberDiff line change
@@ -58,19 +58,23 @@ - (NSDictionary *)nxoauth2_parametersFromEncodedQueryString;
5858

5959
- (NSString *)nxoauth2_URLEncodedString;
6060
{
61-
return (__bridge_transfer NSString *) CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, //Allocator
62-
(__bridge CFStringRef)self, //Original String
63-
NULL, //Characters to leave unescaped
64-
CFSTR("!*'();:@&=+$,/?%#[]"), //Legal Characters to be escaped
65-
kCFStringEncodingUTF8); //Encoding
61+
return [self stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet characterSetWithCharactersInString:@"!*'();:@&=+$,/?%#[]"].invertedSet];
62+
63+
// return (__bridge_transfer NSString *) CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, //Allocator
64+
// (__bridge CFStringRef)self, //Original String
65+
// NULL, //Characters to leave unescaped
66+
// CFSTR("!*'();:@&=+$,/?%#[]"), //Legal Characters to be escaped
67+
// kCFStringEncodingUTF8); //Encoding
6668
}
6769

6870
- (NSString *)nxoauth2_URLDecodedString;
6971
{
70-
return (__bridge_transfer NSString *) CFURLCreateStringByReplacingPercentEscapesUsingEncoding(kCFAllocatorDefault,
71-
(__bridge CFStringRef)self,
72-
CFSTR(""),
73-
kCFStringEncodingUTF8);
72+
return [self stringByRemovingPercentEncoding];
73+
74+
// return (__bridge_transfer NSString *) CFURLCreateStringByReplacingPercentEscapesUsingEncoding(kCFAllocatorDefault,
75+
// (__bridge CFStringRef)self,
76+
// CFSTR(""),
77+
// kCFStringEncodingUTF8);
7478
}
7579

7680
@end

Sources/NSURL+NXOAuth2.h

+2
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,6 @@
2626
- (NSURL *)nxoauth2_URLWithoutQueryString;
2727
- (NSString *)nxoauth2_URLStringWithoutQueryString;
2828

29+
- (NSError*) nxoauth2_redirectURLError;
30+
2931
@end

Sources/NSURL+NXOAuth2.m

+48-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#import "NSString+NXOAuth2.h"
1515

1616
#import "NSURL+NXOAuth2.h"
17-
17+
#import "NXOAuth2Constants.h"
1818

1919
@implementation NSURL (NXOAuth2)
2020

@@ -62,4 +62,51 @@ - (NSString *)nxoauth2_URLStringWithoutQueryString;
6262
return [parts objectAtIndex:0];
6363
}
6464

65+
- (NSError*) nxoauth2_redirectURLError
66+
{
67+
NSURL* redirectURL = self;
68+
NSInteger errorCode = 0;
69+
NSDictionary *userInfo = nil;
70+
NSString *errorString = [redirectURL nxoauth2_valueForQueryParameterKey:@"error"];
71+
if (errorString) {
72+
NSString *localizedError = nil;
73+
74+
if ([errorString caseInsensitiveCompare:@"invalid_request"] == NSOrderedSame) {
75+
errorCode = NXOAuth2InvalidRequestErrorCode;
76+
localizedError = NSLocalizedString(@"Invalid request to OAuth2 Server", @"NXOAuth2InvalidRequestErrorCode description");
77+
78+
} else if ([errorString caseInsensitiveCompare:@"invalid_client"] == NSOrderedSame) {
79+
errorCode = NXOAuth2InvalidClientErrorCode;
80+
localizedError = NSLocalizedString(@"Invalid OAuth2 Client", @"NXOAuth2InvalidClientErrorCode description");
81+
82+
} else if ([errorString caseInsensitiveCompare:@"unauthorized_client"] == NSOrderedSame) {
83+
errorCode = NXOAuth2UnauthorizedClientErrorCode;
84+
localizedError = NSLocalizedString(@"Unauthorized Client", @"NXOAuth2UnauthorizedClientErrorCode description");
85+
86+
} else if ([errorString caseInsensitiveCompare:@"redirect_uri_mismatch"] == NSOrderedSame) {
87+
errorCode = NXOAuth2RedirectURIMismatchErrorCode;
88+
localizedError = NSLocalizedString(@"Redirect URI mismatch", @"NXOAuth2RedirectURIMismatchErrorCode description");
89+
90+
} else if ([errorString caseInsensitiveCompare:@"access_denied"] == NSOrderedSame) {
91+
errorCode = NXOAuth2AccessDeniedErrorCode;
92+
localizedError = NSLocalizedString(@"Access denied", @"NXOAuth2AccessDeniedErrorCode description");
93+
94+
} else if ([errorString caseInsensitiveCompare:@"unsupported_response_type"] == NSOrderedSame) {
95+
errorCode = NXOAuth2UnsupportedResponseTypeErrorCode;
96+
localizedError = NSLocalizedString(@"Unsupported response type", @"NXOAuth2UnsupportedResponseTypeErrorCode description");
97+
98+
} else if ([errorString caseInsensitiveCompare:@"invalid_scope"] == NSOrderedSame) {
99+
errorCode = NXOAuth2InvalidScopeErrorCode;
100+
localizedError = NSLocalizedString(@"Invalid scope", @"NXOAuth2InvalidScopeErrorCode description");
101+
}
102+
103+
if (localizedError) {
104+
userInfo = [NSDictionary dictionaryWithObject:localizedError forKey:NSLocalizedDescriptionKey];
105+
}
106+
}
107+
return [NSError errorWithDomain:NXOAuth2ErrorDomain
108+
code:errorCode
109+
userInfo:userInfo];
110+
}
111+
65112
@end

Sources/OAuth2Client/NXOAuth2AccessToken.h

+8-4
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,14 @@
6666

6767
#pragma mark Keychain Support
6868

69-
//TODO: Support alternate KeyChain Locations
69+
//MIGHTDO: Support alternate KeyChain Locations
70+
+ (instancetype)tokenFromDefaultKeychainWithServiceProviderName:(NSString *)provider
71+
withAccessGroup:(NSString *)accessGroup;
7072

71-
+ (instancetype)tokenFromDefaultKeychainWithServiceProviderName:(NSString *)provider;
72-
- (void)storeInDefaultKeychainWithServiceProviderName:(NSString *)provider;
73-
- (void)removeFromDefaultKeychainWithServiceProviderName:(NSString *)provider;
73+
- (void)storeInDefaultKeychainWithServiceProviderName:(NSString *)provider
74+
withAccessGroup:(NSString *)accessGroup;
75+
76+
- (void)removeFromDefaultKeychainWithServiceProviderName:(NSString *)provider
77+
withAccessGroup:(NSString *)accessGroup;
7478

7579
@end

0 commit comments

Comments
 (0)