diff --git a/NXOAuth2Account+Private.h b/NXOAuth2Account+Private.h index f4dd6e74..b512ff38 100644 --- a/NXOAuth2Account+Private.h +++ b/NXOAuth2Account+Private.h @@ -15,7 +15,10 @@ @interface NXOAuth2Account (Private) -- (id)initAccountWithOAuthClient:(NXOAuth2Client *)oauthClient accountType:(NSString *)accountType; -- (id)initAccountWithAccessToken:(NXOAuth2AccessToken *)accessToken accountType:(NSString *)accountType; +- (instancetype)initAccountWithOAuthClient:(NXOAuth2Client *)oauthClient + accountType:(NSString *)accountType; + +- (instancetype)initAccountWithAccessToken:(NXOAuth2AccessToken *)accessToken + accountType:(NSString *)accountType; @end diff --git a/README.md b/README.md index 2f63867e..77afd698 100755 --- a/README.md +++ b/README.md @@ -122,7 +122,7 @@ If an account was added the `userInfo` dictionary of the notification will conta #### On Failure -If the authentication did not succeed, a notification of type `NXOAuth2AccountStoreDidFailToRequestAccessNotification` containing an `NSError` will be send. +If the authentication did not succeed, a notification of type `NXOAuth2AccountStoreDidFailToRequestAccessNotification` containing an `NSError` will be sent.
 [[NSNotificationCenter defaultCenter] addObserverForName:NXOAuth2AccountStoreDidFailToRequestAccessNotification
                                                   object:[NXOAuth2AccountStore sharedStore]
@@ -157,7 +157,7 @@ NSDictionary *userData = // ...
 account.userData = userData;
 
-This payload will be stored together with the accounts in the Keychain. Thus it shouldn't be to big. +This payload will be stored together with the accounts in the Keychain. Thus it shouldn't be too big. ### Invoking a Request @@ -175,7 +175,7 @@ A request using the authentication for a service can be invoked via `NXOAuth2Req #### Getting a signed NSURLRequest -In some circumstances you have to go the *good old way* and use an `NSURLConnection`. Maybe if you to download a large file. Therefore `NXOAuth2Request` gives you the possibility to get an `NSURLRequest` containing the additional information to authenticate that request. +In some circumstances you have to go the *good old way* and use an `NSURLConnection`. Maybe if you want to download a large file. Therefore `NXOAuth2Request` gives you the possibility to get an `NSURLRequest` containing the additional information to authenticate that request.
 NXOAuth2Request *theRequest = [[NXOAuth2Request alloc] initWithResource:[NSURL URLWithString:@"https://...your service URL..."]
diff --git a/Sources/OAuth2Client/NXOAuth2AccessToken.h b/Sources/OAuth2Client/NXOAuth2AccessToken.h
index 72e4c6c8..d165b974 100644
--- a/Sources/OAuth2Client/NXOAuth2AccessToken.h
+++ b/Sources/OAuth2Client/NXOAuth2AccessToken.h
@@ -33,14 +33,34 @@
 @property (nonatomic, readonly) NSSet *scope;
 @property (nonatomic, readonly) NSString *responseBody;
 
-+ (id)tokenWithResponseBody:(NSString *)responseBody;
-+ (id)tokenWithResponseBody:(NSString *)responseBody tokenType:(NSString *)tokenType;
++ (instancetype)tokenWithResponseBody:(NSString *)responseBody;
 
-- (id)initWithAccessToken:(NSString *)accessToken;
-- (id)initWithAccessToken:(NSString *)accessToken refreshToken:(NSString *)refreshToken expiresAt:(NSDate *)expiryDate;
-- (id)initWithAccessToken:(NSString *)accessToken refreshToken:(NSString *)refreshToken expiresAt:(NSDate *)expiryDate scope:(NSSet *)scope;
-- (id)initWithAccessToken:(NSString *)accessToken refreshToken:(NSString *)refreshToken expiresAt:(NSDate *)expiryDate scope:(NSSet *)scope responseBody:(NSString *)responseBody;
-- (id)initWithAccessToken:(NSString *)accessToken refreshToken:(NSString *)refreshToken expiresAt:(NSDate *)expiryDate scope:(NSSet *)scope responseBody:(NSString *)responseBody tokenType:(NSString*)tokenType; // designated
++ (instancetype)tokenWithResponseBody:(NSString *)responseBody
+                            tokenType:(NSString *)tokenType;
+
+- (instancetype)initWithAccessToken:(NSString *)accessToken;
+
+- (instancetype)initWithAccessToken:(NSString *)accessToken
+                       refreshToken:(NSString *)refreshToken
+                          expiresAt:(NSDate *)expiryDate;
+
+- (instancetype)initWithAccessToken:(NSString *)accessToken
+                       refreshToken:(NSString *)refreshToken
+                          expiresAt:(NSDate *)expiryDate
+                              scope:(NSSet *)scope;
+
+- (instancetype)initWithAccessToken:(NSString *)accessToken
+                       refreshToken:(NSString *)refreshToken
+                          expiresAt:(NSDate *)expiryDate
+                              scope:(NSSet *)scope
+                       responseBody:(NSString *)responseBody;
+
+- (instancetype)initWithAccessToken:(NSString *)accessToken
+                       refreshToken:(NSString *)refreshToken
+                          expiresAt:(NSDate *)expiryDate
+                              scope:(NSSet *)scope
+                       responseBody:(NSString *)responseBody
+                          tokenType:(NSString*)tokenType; // designated
 
 - (void)restoreWithOldToken:(NXOAuth2AccessToken *)oldToken;
 
@@ -48,7 +68,7 @@
 
 //TODO: Support alternate KeyChain Locations
 
-+ (id)tokenFromDefaultKeychainWithServiceProviderName:(NSString *)provider;
++ (instancetype)tokenFromDefaultKeychainWithServiceProviderName:(NSString *)provider;
 - (void)storeInDefaultKeychainWithServiceProviderName:(NSString *)provider;
 - (void)removeFromDefaultKeychainWithServiceProviderName:(NSString *)provider;
 
diff --git a/Sources/OAuth2Client/NXOAuth2AccessToken.m b/Sources/OAuth2Client/NXOAuth2AccessToken.m
index bedef7b8..aefe1c9d 100644
--- a/Sources/OAuth2Client/NXOAuth2AccessToken.m
+++ b/Sources/OAuth2Client/NXOAuth2AccessToken.m
@@ -20,12 +20,12 @@ @implementation NXOAuth2AccessToken
 
 #pragma mark Lifecycle
 
-+ (id)tokenWithResponseBody:(NSString *)theResponseBody;
++ (instancetype)tokenWithResponseBody:(NSString *)theResponseBody;
 {
     return [self tokenWithResponseBody:theResponseBody tokenType:nil];
 }
 
-+ (id)tokenWithResponseBody:(NSString *)theResponseBody tokenType:(NSString *)tokenType;
++ (instancetype)tokenWithResponseBody:(NSString *)theResponseBody tokenType:(NSString *)tokenType;
 {
     NSDictionary *jsonDict = nil;
     Class jsonSerializationClass = NSClassFromString(@"NSJSONSerialization");
@@ -78,12 +78,12 @@ + (id)tokenWithResponseBody:(NSString *)theResponseBody tokenType:(NSString *)to
                                            tokenType:tokenType];
 }
 
-- (id)initWithAccessToken:(NSString *)anAccessToken;
+- (instancetype)initWithAccessToken:(NSString *)anAccessToken;
 {
     return [self initWithAccessToken:anAccessToken refreshToken:nil expiresAt:nil];
 }
 
-- (id)initWithAccessToken:(NSString *)anAccessToken refreshToken:(NSString *)aRefreshToken expiresAt:(NSDate *)anExpiryDate;
+- (instancetype)initWithAccessToken:(NSString *)anAccessToken refreshToken:(NSString *)aRefreshToken expiresAt:(NSDate *)anExpiryDate;
 {
     return [[[self class] alloc] initWithAccessToken:anAccessToken
                                         refreshToken:aRefreshToken
@@ -91,7 +91,7 @@ - (id)initWithAccessToken:(NSString *)anAccessToken refreshToken:(NSString *)aRe
                                                scope:nil];
 }
 
-- (id)initWithAccessToken:(NSString *)anAccessToken refreshToken:(NSString *)aRefreshToken expiresAt:(NSDate *)anExpiryDate scope:(NSSet *)aScope;
+- (instancetype)initWithAccessToken:(NSString *)anAccessToken refreshToken:(NSString *)aRefreshToken expiresAt:(NSDate *)anExpiryDate scope:(NSSet *)aScope;
 {
     return [[[self class] alloc] initWithAccessToken:anAccessToken
                                         refreshToken:aRefreshToken
@@ -100,7 +100,7 @@ - (id)initWithAccessToken:(NSString *)anAccessToken refreshToken:(NSString *)aRe
                                         responseBody:nil];
 }
 
-- (id)initWithAccessToken:(NSString *)anAccessToken refreshToken:(NSString *)aRefreshToken expiresAt:(NSDate *)anExpiryDate scope:(NSSet *)aScope responseBody:(NSString *)aResponseBody;
+- (instancetype)initWithAccessToken:(NSString *)anAccessToken refreshToken:(NSString *)aRefreshToken expiresAt:(NSDate *)anExpiryDate scope:(NSSet *)aScope responseBody:(NSString *)aResponseBody;
 {
     return [[[self class] alloc] initWithAccessToken:anAccessToken
                                         refreshToken:aRefreshToken
@@ -110,7 +110,7 @@ - (id)initWithAccessToken:(NSString *)anAccessToken refreshToken:(NSString *)aRe
                                            tokenType:nil];
 }
 
-- (id)initWithAccessToken:(NSString *)anAccessToken refreshToken:(NSString *)aRefreshToken expiresAt:(NSDate *)anExpiryDate scope:(NSSet *)aScope responseBody:(NSString *)aResponseBody tokenType:(NSString *)aTokenType
+- (instancetype)initWithAccessToken:(NSString *)anAccessToken refreshToken:(NSString *)aRefreshToken expiresAt:(NSDate *)anExpiryDate scope:(NSSet *)aScope responseBody:(NSString *)aResponseBody tokenType:(NSString *)aTokenType
 {
     // a token object without an actual token is not what we want!
     NSAssert1(anAccessToken, @"No token from token response: %@", aResponseBody);
@@ -191,7 +191,7 @@ - (void)encodeWithCoder:(NSCoder *)aCoder
     }
 }
 
-- (id)initWithCoder:(NSCoder *)aDecoder
+- (instancetype)initWithCoder:(NSCoder *)aDecoder
 {
     NSString *decodedAccessToken = [aDecoder decodeObjectForKey:@"accessToken"];
     
@@ -224,7 +224,7 @@ + (NSString *)serviceNameWithProvider:(NSString *)provider;
 
 #if TARGET_OS_IPHONE
 
-+ (id)tokenFromDefaultKeychainWithServiceProviderName:(NSString *)provider;
++ (instancetype)tokenFromDefaultKeychainWithServiceProviderName:(NSString *)provider;
 {
     NSString *serviceName = [[self class] serviceNameWithProvider:provider];
     NSDictionary *result = nil;
@@ -273,7 +273,7 @@ - (void)removeFromDefaultKeychainWithServiceProviderName:(NSString *)provider;
 
 #else
 
-+ (id)tokenFromDefaultKeychainWithServiceProviderName:(NSString *)provider;
++ (instancetype)tokenFromDefaultKeychainWithServiceProviderName:(NSString *)provider;
 {
     NSString *serviceName = [[self class] serviceNameWithProvider:provider];
     
diff --git a/Sources/OAuth2Client/NXOAuth2Account.m b/Sources/OAuth2Client/NXOAuth2Account.m
index 2355a477..fb23df9f 100644
--- a/Sources/OAuth2Client/NXOAuth2Account.m
+++ b/Sources/OAuth2Client/NXOAuth2Account.m
@@ -41,7 +41,7 @@ @implementation NXOAuth2Account (Private)
 
 #pragma mark Lifecycle
 
-- (id)initAccountWithOAuthClient:(NXOAuth2Client *)anOAuthClient accountType:(NSString *)anAccountType;
+- (instancetype)initAccountWithOAuthClient:(NXOAuth2Client *)anOAuthClient accountType:(NSString *)anAccountType;
 {
     self = [self initAccountWithAccessToken:anOAuthClient.accessToken
                                 accountType:anAccountType];
@@ -51,7 +51,7 @@ - (id)initAccountWithOAuthClient:(NXOAuth2Client *)anOAuthClient accountType:(NS
     return self;
 }
 
-- (id)initAccountWithAccessToken:(NXOAuth2AccessToken *)anAccessToken accountType:(NSString *)anAccountType;
+- (instancetype)initAccountWithAccessToken:(NXOAuth2AccessToken *)anAccessToken accountType:(NSString *)anAccountType;
 {
     self = [super init];
     if (self) {
@@ -202,7 +202,7 @@ - (void)encodeWithCoder:(NSCoder *)aCoder
     [aCoder encodeObject:userData forKey:@"userData"];
 }
 
-- (id)initWithCoder:(NSCoder *)aDecoder
+- (instancetype)initWithCoder:(NSCoder *)aDecoder
 {
     if (self = [super init]) {
         userData = [aDecoder decodeObjectForKey:@"userData"];
diff --git a/Sources/OAuth2Client/NXOAuth2AccountStore.h b/Sources/OAuth2Client/NXOAuth2AccountStore.h
index 05945884..0a5bc74a 100644
--- a/Sources/OAuth2Client/NXOAuth2AccountStore.h
+++ b/Sources/OAuth2Client/NXOAuth2AccountStore.h
@@ -75,7 +75,7 @@ typedef void(^NXOAuth2PreparedAuthorizationURLHandler)(NSURL *preparedURL);
     NSMutableDictionary *trustedCertificatesHandler;
 }
 
-+ (id)sharedStore;
++ (instancetype)sharedStore;
 
 #pragma mark Accessors
 
diff --git a/Sources/OAuth2Client/NXOAuth2AccountStore.m b/Sources/OAuth2Client/NXOAuth2AccountStore.m
index 45815ec4..b36a9de1 100644
--- a/Sources/OAuth2Client/NXOAuth2AccountStore.m
+++ b/Sources/OAuth2Client/NXOAuth2AccountStore.m
@@ -87,7 +87,7 @@ @implementation NXOAuth2AccountStore
 
 #pragma mark Lifecycle
 
-+ (id)sharedStore;
++ (instancetype)sharedStore;
 {
     static NXOAuth2AccountStore *shared;
     static dispatch_once_t onceToken;
@@ -97,7 +97,7 @@ + (id)sharedStore;
     return shared;
 }
 
-- (id)init;
+- (instancetype)init;
 {
     self = [super init];
     if (self) {
diff --git a/Sources/OAuth2Client/NXOAuth2Client.h b/Sources/OAuth2Client/NXOAuth2Client.h
index f5295c28..c9b3e3de 100644
--- a/Sources/OAuth2Client/NXOAuth2Client.h
+++ b/Sources/OAuth2Client/NXOAuth2Client.h
@@ -85,30 +85,30 @@ extern NSString * const NXOAuth2ClientConnectionContextTokenRefresh;
 /*!
  * Initializes the Client
  */
-- (id)initWithClientID:(NSString *)clientId
-          clientSecret:(NSString *)clientSecret
-          authorizeURL:(NSURL *)authorizeURL
-              tokenURL:(NSURL *)tokenURL
-              delegate:(NSObject *)delegate;
-
-- (id)initWithClientID:(NSString *)clientId
-          clientSecret:(NSString *)clientSecret
-          authorizeURL:(NSURL *)authorizeURL
-              tokenURL:(NSURL *)tokenURL
-           accessToken:(NXOAuth2AccessToken *)accessToken
-         keyChainGroup:(NSString *)keyChainGroup
-            persistent:(BOOL)shouldPersist
-              delegate:(NSObject *)delegate;
-
-- (id)initWithClientID:(NSString *)clientId
-          clientSecret:(NSString *)clientSecret
-          authorizeURL:(NSURL *)authorizeURL
-              tokenURL:(NSURL *)tokenURL
-           accessToken:(NXOAuth2AccessToken *)accessToken
-             tokenType:(NSString *)tokenType
-         keyChainGroup:(NSString *)keyChainGroup
-            persistent:(BOOL)shouldPersist
-              delegate:(NSObject *)delegate;
+- (instancetype)initWithClientID:(NSString *)clientId
+                    clientSecret:(NSString *)clientSecret
+                    authorizeURL:(NSURL *)authorizeURL
+                        tokenURL:(NSURL *)tokenURL
+                        delegate:(NSObject *)delegate;
+
+- (instancetype)initWithClientID:(NSString *)clientId
+                    clientSecret:(NSString *)clientSecret
+                    authorizeURL:(NSURL *)authorizeURL
+                        tokenURL:(NSURL *)tokenURL
+                     accessToken:(NXOAuth2AccessToken *)accessToken
+                   keyChainGroup:(NSString *)keyChainGroup
+                      persistent:(BOOL)shouldPersist
+                        delegate:(NSObject *)delegate;
+
+- (instancetype)initWithClientID:(NSString *)clientId
+                    clientSecret:(NSString *)clientSecret
+                    authorizeURL:(NSURL *)authorizeURL
+                        tokenURL:(NSURL *)tokenURL
+                     accessToken:(NXOAuth2AccessToken *)accessToken
+                       tokenType:(NSString *)tokenType
+                   keyChainGroup:(NSString *)keyChainGroup
+                      persistent:(BOOL)shouldPersist
+                        delegate:(NSObject *)delegate;
 
 - (BOOL)openRedirectURL:(NSURL *)URL;
 
diff --git a/Sources/OAuth2Client/NXOAuth2Client.m b/Sources/OAuth2Client/NXOAuth2Client.m
index 2dfa0f6e..dd3843e2 100644
--- a/Sources/OAuth2Client/NXOAuth2Client.m
+++ b/Sources/OAuth2Client/NXOAuth2Client.m
@@ -37,11 +37,11 @@ @implementation NXOAuth2Client
 
 #pragma mark Lifecycle
 
-- (id)initWithClientID:(NSString *)aClientId
-          clientSecret:(NSString *)aClientSecret
-          authorizeURL:(NSURL *)anAuthorizeURL
-              tokenURL:(NSURL *)aTokenURL
-              delegate:(NSObject *)aDelegate;
+- (instancetype)initWithClientID:(NSString *)aClientId
+                    clientSecret:(NSString *)aClientSecret
+                    authorizeURL:(NSURL *)anAuthorizeURL
+                        tokenURL:(NSURL *)aTokenURL
+                        delegate:(NSObject *)aDelegate;
 {
     return [self initWithClientID:aClientId
                      clientSecret:aClientSecret
@@ -53,14 +53,14 @@ - (id)initWithClientID:(NSString *)aClientId
                          delegate:aDelegate];
 }
 
-- (id)initWithClientID:(NSString *)aClientId
-          clientSecret:(NSString *)aClientSecret
-          authorizeURL:(NSURL *)anAuthorizeURL
-              tokenURL:(NSURL *)aTokenURL
-           accessToken:(NXOAuth2AccessToken *)anAccessToken
-         keyChainGroup:(NSString *)aKeyChainGroup
-            persistent:(BOOL)shouldPersist
-              delegate:(NSObject *)aDelegate;
+- (instancetype)initWithClientID:(NSString *)aClientId
+                    clientSecret:(NSString *)aClientSecret
+                    authorizeURL:(NSURL *)anAuthorizeURL
+                        tokenURL:(NSURL *)aTokenURL
+                     accessToken:(NXOAuth2AccessToken *)anAccessToken
+                   keyChainGroup:(NSString *)aKeyChainGroup
+                      persistent:(BOOL)shouldPersist
+                        delegate:(NSObject *)aDelegate;
 {
     return [self initWithClientID:aClientId
                      clientSecret:aClientSecret
@@ -73,15 +73,15 @@ - (id)initWithClientID:(NSString *)aClientId
                          delegate:aDelegate];
 }
 
-- (id)initWithClientID:(NSString *)aClientId
-          clientSecret:(NSString *)aClientSecret
-          authorizeURL:(NSURL *)anAuthorizeURL
-              tokenURL:(NSURL *)aTokenURL
-           accessToken:(NXOAuth2AccessToken *)anAccessToken
-             tokenType:(NSString *)aTokenType
-         keyChainGroup:(NSString *)aKeyChainGroup
-            persistent:(BOOL)shouldPersist
-              delegate:(NSObject *)aDelegate;
+- (instancetype)initWithClientID:(NSString *)aClientId
+                    clientSecret:(NSString *)aClientSecret
+                    authorizeURL:(NSURL *)anAuthorizeURL
+                        tokenURL:(NSURL *)aTokenURL
+                     accessToken:(NXOAuth2AccessToken *)anAccessToken
+                       tokenType:(NSString *)aTokenType
+                   keyChainGroup:(NSString *)aKeyChainGroup
+                      persistent:(BOOL)shouldPersist
+                        delegate:(NSObject *)aDelegate;
 {
     NSAssert(aTokenURL != nil && anAuthorizeURL != nil, @"No token or no authorize URL");
     self = [super init];
diff --git a/Sources/OAuth2Client/NXOAuth2Connection.h b/Sources/OAuth2Client/NXOAuth2Connection.h
index ef41164c..c29feb54 100644
--- a/Sources/OAuth2Client/NXOAuth2Connection.h
+++ b/Sources/OAuth2Client/NXOAuth2Connection.h
@@ -87,16 +87,16 @@ typedef void(^NXOAuth2ConnectionSendingProgressHandler)(unsigned long long bytes
 @property (nonatomic, strong) NSDictionary *userInfo;
 @property (nonatomic, strong, readonly) NXOAuth2Client *client;
 
-- (id) initWithRequest:(NSMutableURLRequest *)request
-     requestParameters:(NSDictionary *)requestParameters
-           oauthClient:(NXOAuth2Client *)client
-sendingProgressHandler:(NXOAuth2ConnectionSendingProgressHandler)sendingProgressHandler
-       responseHandler:(NXOAuth2ConnectionResponseHandler)responseHandler;
-
-- (id)initWithRequest:(NSMutableURLRequest *)request
-    requestParameters:(NSDictionary *)requestParameters
-          oauthClient:(NXOAuth2Client *)client
-             delegate:(NSObject *)delegate;
+- (instancetype) initWithRequest:(NSMutableURLRequest *)request
+               requestParameters:(NSDictionary *)requestParameters
+                     oauthClient:(NXOAuth2Client *)client
+          sendingProgressHandler:(NXOAuth2ConnectionSendingProgressHandler)sendingProgressHandler
+                 responseHandler:(NXOAuth2ConnectionResponseHandler)responseHandler;
+
+- (instancetype)initWithRequest:(NSMutableURLRequest *)request
+              requestParameters:(NSDictionary *)requestParameters
+                    oauthClient:(NXOAuth2Client *)client
+                       delegate:(NSObject *)delegate;
 
 - (void)cancel;
 
diff --git a/Sources/OAuth2Client/NXOAuth2Connection.m b/Sources/OAuth2Client/NXOAuth2Connection.m
index a324850b..ef2d2a9f 100644
--- a/Sources/OAuth2Client/NXOAuth2Connection.m
+++ b/Sources/OAuth2Client/NXOAuth2Connection.m
@@ -64,10 +64,10 @@ -  (id)initWithRequest:(NSMutableURLRequest *)aRequest
     return self;
 }
 
-- (id)initWithRequest:(NSMutableURLRequest *)aRequest
-    requestParameters:(NSDictionary *)someRequestParameters
-          oauthClient:(NXOAuth2Client *)aClient
-             delegate:(NSObject *)aDelegate;
+- (instancetype)initWithRequest:(NSMutableURLRequest *)aRequest
+              requestParameters:(NSDictionary *)someRequestParameters
+                    oauthClient:(NXOAuth2Client *)aClient
+                       delegate:(NSObject *)aDelegate;
 {
     self = [super init];
     if (self) {
diff --git a/Sources/OAuth2Client/NXOAuth2FileStreamWrapper.h b/Sources/OAuth2Client/NXOAuth2FileStreamWrapper.h
index 590c8d43..f4542cdd 100755
--- a/Sources/OAuth2Client/NXOAuth2FileStreamWrapper.h
+++ b/Sources/OAuth2Client/NXOAuth2FileStreamWrapper.h
@@ -25,11 +25,18 @@
 @property (nonatomic, copy, readonly) NSString *fileName;
 @property (nonatomic, copy) NSString *contentType; // optional DEFAULT: "application/octettstream"
 
-+ (id)wrapperWithStream:(NSInputStream *)stream contentLength:(unsigned long long)contentLength DEPRECATED_ATTRIBUTE;
-- (id)initWithStream:(NSInputStream *)stream contentLength:(unsigned long long)contentLength DEPRECATED_ATTRIBUTE;
++ (instancetype)wrapperWithStream:(NSInputStream *)stream
+                    contentLength:(unsigned long long)contentLength DEPRECATED_ATTRIBUTE;
 
-+ (id)wrapperWithStream:(NSInputStream *)stream contentLength:(unsigned long long)contentLength fileName:(NSString *)fileName;
-- (id)initWithStream:(NSInputStream *)stream contentLength:(unsigned long long)contentLength fileName:(NSString *)fileName;
+- (instancetype)initWithStream:(NSInputStream *)stream
+                 contentLength:(unsigned long long)contentLength DEPRECATED_ATTRIBUTE;
 
++ (instancetype)wrapperWithStream:(NSInputStream *)stream
+                    contentLength:(unsigned long long)contentLength
+                         fileName:(NSString *)fileName;
+
+- (instancetype)initWithStream:(NSInputStream *)stream
+                 contentLength:(unsigned long long)contentLength
+                      fileName:(NSString *)fileName;
 
 @end
diff --git a/Sources/OAuth2Client/NXOAuth2FileStreamWrapper.m b/Sources/OAuth2Client/NXOAuth2FileStreamWrapper.m
index 11b7678a..c7fb6ec9 100755
--- a/Sources/OAuth2Client/NXOAuth2FileStreamWrapper.m
+++ b/Sources/OAuth2Client/NXOAuth2FileStreamWrapper.m
@@ -18,12 +18,12 @@ @implementation NXOAuth2FileStreamWrapper
 
 #pragma mark Class Methods
 
-+ (id)wrapperWithStream:(NSInputStream *)aStream contentLength:(unsigned long long)aContentLength;
++ (instancetype)wrapperWithStream:(NSInputStream *)aStream contentLength:(unsigned long long)aContentLength;
 {
     return [self wrapperWithStream:aStream contentLength:aContentLength fileName:nil];
 }
 
-+ (id)wrapperWithStream:(NSInputStream *)aStream contentLength:(unsigned long long)aContentLength fileName:(NSString *)aFileName;
++ (instancetype)wrapperWithStream:(NSInputStream *)aStream contentLength:(unsigned long long)aContentLength fileName:(NSString *)aFileName;
 {
     return [[self alloc] initWithStream:aStream contentLength:aContentLength fileName:aFileName];
 }
@@ -31,18 +31,18 @@ + (id)wrapperWithStream:(NSInputStream *)aStream contentLength:(unsigned long lo
 
 #pragma mark Lifecycle
 
-- (id)init;
+- (instancetype)init;
 {
     NSAssert(NO, @"-init should not be used in the NXOAuth2FileStreamWrapper");
     return nil;
 }
 
-- (id)initWithStream:(NSInputStream *)theStream contentLength:(unsigned long long)theContentLength;
+- (instancetype)initWithStream:(NSInputStream *)theStream contentLength:(unsigned long long)theContentLength;
 {
     return [self initWithStream:theStream contentLength:theContentLength fileName:nil];
 }
 
-- (id)initWithStream:(NSInputStream *)aStream contentLength:(unsigned long long)aContentLength fileName:(NSString *)aFileName;
+- (instancetype)initWithStream:(NSInputStream *)aStream contentLength:(unsigned long long)aContentLength fileName:(NSString *)aFileName;
 {
     if (!aFileName) aFileName = @"unknown";
     
diff --git a/Sources/OAuth2Client/NXOAuth2PostBodyPart.h b/Sources/OAuth2Client/NXOAuth2PostBodyPart.h
index d83cf6d2..f0376bab 100644
--- a/Sources/OAuth2Client/NXOAuth2PostBodyPart.h
+++ b/Sources/OAuth2Client/NXOAuth2PostBodyPart.h
@@ -34,12 +34,22 @@
  *    - NSData
  *    - NXOAuth2FileStreamWrapper
  */
-+ (id)partWithName:(NSString *)name content:(id)content;
-- (id)initWithName:(NSString *)name content:(id)content;
++ (instancetype)partWithName:(NSString *)name
+                     content:(id)content;
 
-- (id)initWithHeaders:(NSString *)headers dataContent:(NSData *)data;
-- (id)initWithName:(NSString *)name streamContent:(NSInputStream *)stream streamLength:(unsigned long long)streamLength fileName:(NSString *)fileName;
+- (instancetype)initWithName:(NSString *)name
+                     content:(id)content;
 
-- (id)initWithHeaders:(NSString *)headers streamContent:(NSInputStream *)stream length:(unsigned long long)length; //designated initializer
+- (instancetype)initWithHeaders:(NSString *)headers
+                    dataContent:(NSData *)data;
+
+- (instancetype)initWithName:(NSString *)name
+               streamContent:(NSInputStream *)stream
+                streamLength:(unsigned long long)streamLength
+                    fileName:(NSString *)fileName;
+
+- (instancetype)initWithHeaders:(NSString *)headers
+                  streamContent:(NSInputStream *)stream
+                         length:(unsigned long long)length; //designated initializer
 
 @end
diff --git a/Sources/OAuth2Client/NXOAuth2PostBodyPart.m b/Sources/OAuth2Client/NXOAuth2PostBodyPart.m
index 74d030d6..6c8345a5 100644
--- a/Sources/OAuth2Client/NXOAuth2PostBodyPart.m
+++ b/Sources/OAuth2Client/NXOAuth2PostBodyPart.m
@@ -17,9 +17,9 @@
 
 
 @interface NXOAuth2PostBodyPart(Private)
-- (id)initWithName:(NSString *)name dataContent:(NSData *)data;
-- (id)initWithName:(NSString *)name fileContent:(NSString *)path;
-- (id)initWithName:(NSString *)name stringContent:(NSString *)string;
+- (instancetype)initWithName:(NSString *)name dataContent:(NSData *)data;
+- (instancetype)initWithName:(NSString *)name fileContent:(NSString *)path;
+- (instancetype)initWithName:(NSString *)name stringContent:(NSString *)string;
 @end
 
 
@@ -27,12 +27,12 @@ @implementation NXOAuth2PostBodyPart
 
 #pragma mark Lifecycle
 
-+ (id)partWithName:(NSString *)name content:(id)content;
++ (instancetype)partWithName:(NSString *)name content:(id)content;
 {
     return [[self alloc] initWithName:name content:content];
 }
 
-- (id)initWithName:(NSString *)name content:(id)content;
+- (instancetype)initWithName:(NSString *)name content:(id)content;
 {
     if ([content isKindOfClass:[NSString class]]) {
         return [self initWithName:name stringContent:content];
@@ -50,7 +50,7 @@ - (id)initWithName:(NSString *)name content:(id)content;
     }
 }
 
-- (id)initWithName:(NSString *)name streamContent:(NSInputStream *)stream streamLength:(unsigned long long)streamLength fileName:(NSString *)fileName;
+- (instancetype)initWithName:(NSString *)name streamContent:(NSInputStream *)stream streamLength:(unsigned long long)streamLength fileName:(NSString *)fileName;
 {
     NSMutableString *headers = [NSMutableString string];
     [headers appendFormat:@"Content-Disposition: form-data; name=\"%@\"; filename=\"%@\"\r\n", name, fileName];
@@ -60,7 +60,7 @@ - (id)initWithName:(NSString *)name streamContent:(NSInputStream *)stream stream
     return [self initWithHeaders:headers streamContent:stream length:streamLength];
 }
 
-- (id)initWithName:(NSString *)name streamContent:(NSInputStream *)stream streamLength:(unsigned long long)streamLength fileName:(NSString *)fileName contentType:(NSString *)contentType;
+- (instancetype)initWithName:(NSString *)name streamContent:(NSInputStream *)stream streamLength:(unsigned long long)streamLength fileName:(NSString *)fileName contentType:(NSString *)contentType;
 {
     NSMutableString *headers = [NSMutableString string];
     [headers appendFormat:@"Content-Disposition: form-data; name=\"%@\"; filename=\"%@\"\r\n", name, fileName];
@@ -70,7 +70,7 @@ - (id)initWithName:(NSString *)name streamContent:(NSInputStream *)stream stream
     return [self initWithHeaders:headers streamContent:stream length:streamLength];
 }
 
-- (id)initWithName:(NSString *)name dataContent:(NSData *)data;
+- (instancetype)initWithName:(NSString *)name dataContent:(NSData *)data;
 {
     NSMutableString *headers = [NSMutableString string];
     [headers appendFormat:@"Content-Disposition: form-data; name=\"%@\"; filename=\"unknown\"\r\n", name];
@@ -80,7 +80,7 @@ - (id)initWithName:(NSString *)name dataContent:(NSData *)data;
     return [self initWithHeaders:headers dataContent:data];
 }
 
-- (id)initWithName:(NSString *)name fileContent:(NSString *)path;
+- (instancetype)initWithName:(NSString *)name fileContent:(NSString *)path;
 {
     NSMutableString *headers = [NSMutableString string];
     [headers appendFormat:@"Content-Disposition: form-data; name=\"%@\"; filename=\"%@\"\r\n", name, [path lastPathComponent]];
@@ -100,7 +100,7 @@ - (id)initWithName:(NSString *)name fileContent:(NSString *)path;
                           length:[fileSize unsignedLongLongValue]];
 }
 
-- (id)initWithName:(NSString *)name stringContent:(NSString *)string;
+- (instancetype)initWithName:(NSString *)name stringContent:(NSString *)string;
 {
     NSMutableString *headers = [NSMutableString string];
     [headers appendFormat:@"Content-Disposition: form-data; name=\"%@\"\r\n", name];
@@ -108,14 +108,14 @@ - (id)initWithName:(NSString *)name stringContent:(NSString *)string;
     return [self initWithHeaders:headers dataContent:[string dataUsingEncoding:NSUTF8StringEncoding]];
 }
 
-- (id)initWithHeaders:(NSString *)headers dataContent:(NSData *)data;
+- (instancetype)initWithHeaders:(NSString *)headers dataContent:(NSData *)data;
 {
     return [self initWithHeaders: headers
                    streamContent: [NSInputStream inputStreamWithData:data]
                           length: [data length]];
 }
 
-- (id)initWithHeaders:(NSString *)headers streamContent:(NSInputStream *)stream length:(unsigned long long)length;
+- (instancetype)initWithHeaders:(NSString *)headers streamContent:(NSInputStream *)stream length:(unsigned long long)length;
 {
     self = [super init];
     if(self) {
diff --git a/Sources/OAuth2Client/NXOAuth2PostBodyStream.h b/Sources/OAuth2Client/NXOAuth2PostBodyStream.h
index 9745db28..c08ea013 100644
--- a/Sources/OAuth2Client/NXOAuth2PostBodyStream.h
+++ b/Sources/OAuth2Client/NXOAuth2PostBodyStream.h
@@ -25,7 +25,7 @@
     unsigned long long numBytesTotal;
 }
 
-- (id)initWithParameters:(NSDictionary *)postParameters;
+- (instancetype)initWithParameters:(NSDictionary *)postParameters;
 
 @property (readonly) NSString *boundary;
 @property (readonly) unsigned long long length;
diff --git a/Sources/OAuth2Client/NXOAuth2PostBodyStream.m b/Sources/OAuth2Client/NXOAuth2PostBodyStream.m
index 8b156d84..92855402 100644
--- a/Sources/OAuth2Client/NXOAuth2PostBodyStream.m
+++ b/Sources/OAuth2Client/NXOAuth2PostBodyStream.m
@@ -26,7 +26,7 @@ @implementation NXOAuth2PostBodyStream
 
 #pragma mark Lifecycle
 
-- (id)initWithParameters:(NSDictionary *)postParameters;
+- (instancetype)initWithParameters:(NSDictionary *)postParameters;
 {
     self = [self init];
     if (self) {
diff --git a/Sources/OAuth2Client/NXOAuth2Request.h b/Sources/OAuth2Client/NXOAuth2Request.h
index 3bc2c270..abb0fe61 100644
--- a/Sources/OAuth2Client/NXOAuth2Request.h
+++ b/Sources/OAuth2Client/NXOAuth2Request.h
@@ -40,7 +40,9 @@
 
 #pragma mark Lifecycle
 
-- (id)initWithResource:(NSURL *)url method:(NSString *)method parameters:(NSDictionary *)parameter;
+- (instancetype)initWithResource:(NSURL *)url
+                          method:(NSString *)method
+                      parameters:(NSDictionary *)parameter;
 
 
 #pragma mark Accessors
@@ -62,6 +64,9 @@
 - (void)performRequestWithSendingProgressHandler:(NXOAuth2ConnectionSendingProgressHandler)progressHandler
                                  responseHandler:(NXOAuth2ConnectionResponseHandler)responseHandler;
 
+- (void)performRequestWithProgressHandler:(NXOAuth2ConnectionSendingProgressHandler)progressHandler
+                          responseHandler:(NXOAuth2ConnectionResponseHandler)responseHandler;
+
 
 #pragma mark Cancel
 
diff --git a/Sources/OAuth2Client/NXOAuth2Request.m b/Sources/OAuth2Client/NXOAuth2Request.m
index 680546c3..c65fa731 100644
--- a/Sources/OAuth2Client/NXOAuth2Request.m
+++ b/Sources/OAuth2Client/NXOAuth2Request.m
@@ -25,6 +25,7 @@
 @interface NXOAuth2Request () 
 @property (nonatomic,  strong, readwrite) NXOAuth2Connection *connection;
 @property (nonatomic,  strong, readwrite) NXOAuth2Request *me;
+@property (nonatomic,  copy) NXOAuth2ConnectionSendingProgressHandler progressHandler;
 #pragma mark Apply Parameters
 - (void)applyParameters:(NSDictionary *)someParameters onRequest:(NSMutableURLRequest *)aRequest;
 @end
@@ -51,7 +52,7 @@ + (void)performMethod:(NSString *)aMethod
 
 #pragma mark Lifecycle
 
-- (id)initWithResource:(NSURL *)aResource method:(NSString *)aMethod parameters:(NSDictionary *)someParameters;
+- (instancetype)initWithResource:(NSURL *)aResource method:(NSString *)aMethod parameters:(NSDictionary *)someParameters;
 {
     self = [super init];
     if (self) {
@@ -116,6 +117,12 @@ - (void)performRequestWithSendingProgressHandler:(NXOAuth2ConnectionSendingProgr
     self.me = self;
 }
 
+- (void)performRequestWithProgressHandler:(NXOAuth2ConnectionSendingProgressHandler)progressHandler
+                          responseHandler:(NXOAuth2ConnectionResponseHandler)responseHandler;
+{
+    self.progressHandler = progressHandler;
+    [self performRequestWithSendingProgressHandler:progressHandler responseHandler:responseHandler];
+}
 
 #pragma mark Cancel
 
@@ -149,6 +156,13 @@ - (void)oauthConnection:(NXOAuth2Connection *)connection didFailWithError:(NSErr
     self.me = nil;
 }
 
+-(void)oauthConnection:(NXOAuth2Connection *)connectionStbl didReceiveData:(NSData *)data
+{
+    if (self.progressHandler)
+    {
+        self.progressHandler(self.connection.data.length, connectionStbl.expectedContentLength);
+    }
+}
 
 #pragma mark Apply Parameters