Skip to content
This repository has been archived by the owner on Jan 17, 2023. It is now read-only.

Commit

Permalink
Initial compiling checkin
Browse files Browse the repository at this point in the history
  • Loading branch information
kcharwood committed Dec 7, 2015
1 parent 10f7e27 commit 2aa4ba7
Show file tree
Hide file tree
Showing 84 changed files with 26,026 additions and 14 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
.DS_Store
## Build generated
build/
DerivedData

## Various settings
Expand Down
8 changes: 8 additions & 0 deletions AFOAuth2Manager.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
objects = {

/* Begin PBXBuildFile section */
2934F28E1C15D9BE008B8AE4 /* AFOAuthCredential.h in Headers */ = {isa = PBXBuildFile; fileRef = 2934F28C1C15D9BE008B8AE4 /* AFOAuthCredential.h */; };
2934F28F1C15D9BE008B8AE4 /* AFOAuthCredential.m in Sources */ = {isa = PBXBuildFile; fileRef = 2934F28D1C15D9BE008B8AE4 /* AFOAuthCredential.m */; };
29490FD51BE11C5100893BE1 /* AFHTTPRequestSerializer+OAuth2.h in Headers */ = {isa = PBXBuildFile; fileRef = 29490FD11BE11C5100893BE1 /* AFHTTPRequestSerializer+OAuth2.h */; };
29490FD71BE11C5100893BE1 /* AFOAuth2Manager.h in Headers */ = {isa = PBXBuildFile; fileRef = 29490FD31BE11C5100893BE1 /* AFOAuth2Manager.h */; };
29490FDD1BE11CBB00893BE1 /* AFNetworking.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 29490FDC1BE11CBB00893BE1 /* AFNetworking.framework */; };
Expand All @@ -15,6 +17,8 @@
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
2934F28C1C15D9BE008B8AE4 /* AFOAuthCredential.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFOAuthCredential.h; sourceTree = "<group>"; };
2934F28D1C15D9BE008B8AE4 /* AFOAuthCredential.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFOAuthCredential.m; sourceTree = "<group>"; };
29490FC51BE11BD700893BE1 /* AFOAuth2Manager.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = AFOAuth2Manager.framework; sourceTree = BUILT_PRODUCTS_DIR; };
29490FD11BE11C5100893BE1 /* AFHTTPRequestSerializer+OAuth2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "AFHTTPRequestSerializer+OAuth2.h"; sourceTree = "<group>"; };
29490FD21BE11C5100893BE1 /* AFHTTPRequestSerializer+OAuth2.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "AFHTTPRequestSerializer+OAuth2.m"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -66,6 +70,8 @@
29490FD41BE11C5100893BE1 /* AFOAuth2Manager.m */,
29490FDE1BE11D1000893BE1 /* AFOAuth2SessionManager.h */,
29490FDF1BE11D1000893BE1 /* AFOAuth2SessionManager.m */,
2934F28C1C15D9BE008B8AE4 /* AFOAuthCredential.h */,
2934F28D1C15D9BE008B8AE4 /* AFOAuthCredential.m */,
);
path = AFOAuth2Manager;
sourceTree = "<group>";
Expand All @@ -86,6 +92,7 @@
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
2934F28E1C15D9BE008B8AE4 /* AFOAuthCredential.h in Headers */,
29490FE01BE11D1000893BE1 /* AFOAuth2SessionManager.h in Headers */,
29490FD71BE11C5100893BE1 /* AFOAuth2Manager.h in Headers */,
29490FD51BE11C5100893BE1 /* AFHTTPRequestSerializer+OAuth2.h in Headers */,
Expand Down Expand Up @@ -160,6 +167,7 @@
buildActionMask = 2147483647;
files = (
29490FE11BE11D1000893BE1 /* AFOAuth2SessionManager.m in Sources */,
2934F28F1C15D9BE008B8AE4 /* AFOAuthCredential.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "29490FC41BE11BD700893BE1"
BuildableName = "AFOAuth2Manager iOS.framework"
BuildableName = "AFOAuth2Manager.framework"
BlueprintName = "AFOAuth2Manager iOS"
ReferencedContainer = "container:AFOAuth2Manager.xcodeproj">
</BuildableReference>
Expand Down Expand Up @@ -46,7 +46,7 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "29490FC41BE11BD700893BE1"
BuildableName = "AFOAuth2Manager iOS.framework"
BuildableName = "AFOAuth2Manager.framework"
BlueprintName = "AFOAuth2Manager iOS"
ReferencedContainer = "container:AFOAuth2Manager.xcodeproj">
</BuildableReference>
Expand All @@ -64,7 +64,7 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "29490FC41BE11BD700893BE1"
BuildableName = "AFOAuth2Manager iOS.framework"
BuildableName = "AFOAuth2Manager.framework"
BlueprintName = "AFOAuth2Manager iOS"
ReferencedContainer = "container:AFOAuth2Manager.xcodeproj">
</BuildableReference>
Expand Down
133 changes: 129 additions & 4 deletions AFOAuth2Manager/AFOAuth2SessionManager.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,139 @@
// AFOAuth2SessionManager.h
//
// AFOAuth2SessionManager.h
// AFOAuth2Manager
// Copyright (c) 2012-2014 AFNetworking (http://afnetworking.com)
//
// Created by Kevin Harwood on 10/28/15.
// Copyright © 2015 Alamofire. All rights reserved.
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE

#import <UIKit/UIKit.h>
@class AFOAuthCredential;
@import AFNetworking;

NS_ASSUME_NONNULL_BEGIN

@interface AFOAuth2SessionManager : AFHTTPSessionManager

///------------------------------------------
/// @name Accessing OAuth 2 Client Properties
///------------------------------------------

/**
The service provider identifier used to store and retrieve OAuth credentials by `AFOAuthCredential`. Equivalent to the hostname of the client `baseURL`.
*/
@property (readonly, nonatomic, copy) NSString *serviceProviderIdentifier;

/**
The client identifier issued by the authorization server, uniquely representing the registration information provided by the client.
*/
@property (readonly, nonatomic, copy) NSString *clientID;

/**
Whether to encode client credentials in a Base64-encoded HTTP `Authorization` header, as opposed to the request body. Defaults to `YES`.
*/
@property (nonatomic, assign) BOOL useHTTPBasicAuthentication;

///------------------------------------------------
/// @name Creating and Initializing OAuth 2 Managers
///------------------------------------------------

/**
Creates and initializes an `AFOAuth2SessionManager` object with the specified base URL, client identifier, and secret.
@param url The base URL for the HTTP client. This argument must not be `nil`.
@param clientID The client identifier issued by the authorization server, uniquely representing the registration information provided by the client. This argument must not be `nil`.
@param secret The client secret.
@return The newly-initialized OAuth 2 manager
*/
+ (instancetype)managerWithBaseURL:(NSURL *)url
clientID:(NSString *)clientID
secret:(NSString *)secret;

+ (instancetype)managerWithBaseURL:(NSURL *)url
sessionConfiguration:(nullable NSURLSessionConfiguration *)configuration
clientID:(NSString *)clientID
secret:(NSString *)secret;

/**
Initializes an `AFOAuth2SessionManager` object with the specified base URL, client identifier, and secret. The communication to to the server will use HTTP basic auth by default (use `-(id)initWithBaseURL:clientID:secret:withBasicAuth:` to change this).
@param url The base URL for the HTTP manager. This argument must not be `nil`.
@param clientID The client identifier issued by the authorization server, uniquely representing the registration information provided by the client. This argument must not be `nil`.
@param secret The client secret.
@return The newly-initialized OAuth 2 client
*/
- (id)initWithBaseURL:(NSURL *)url
clientID:(NSString *)clientID
secret:(NSString *)secret;

- (id)initWithBaseURL:(NSURL *)url
sessionConfiguration:(nullable NSURLSessionConfiguration *)configuration
clientID:(NSString *)clientID
secret:(NSString *)secret;

///---------------------
/// @name Authenticating
///---------------------

/**
Creates and enqueues an `NSURLSessionTask` to authenticate against the server using a specified username and password, with a designated scope.
@param URLString The URL string used to create the request URL.
@param username The username used for authentication
@param password The password used for authentication
@param scope The authorization scope
@param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes a single argument: the OAuth credential returned by the server.
@param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a single argument: the error returned from the server.
*/
- (NSURLSessionTask *)authenticateUsingOAuthWithURLString:(NSString *)URLString
username:(NSString *)username
password:(NSString *)password
scope:(NSString *)scope
success:(void (^)(AFOAuthCredential *credential))success
failure:(void (^)(NSError *error))failure;

/**
Creates and enqueues an `NSURLSessionTask` to authenticate against the server with a designated scope.
@param URLString The URL string used to create the request URL.
@param scope The authorization scope
@param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes a single argument: the OAuth credential returned by the server.
@param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a single argument: the error returned from the server.
*/
- (NSURLSessionTask *)authenticateUsingOAuthWithURLString:(NSString *)URLString
scope:(NSString *)scope
success:(void (^)(AFOAuthCredential *credential))success
failure:(void (^)(NSError *error))failure;

/**
Creates and enqueues an `NSURLSessionTask` to authenticate against the server with the specified parameters.
@param URLString The URL string used to create the request URL.
@param parameters The parameters to be encoded and set in the request HTTP body.
@param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes a single argument: the OAuth credential returned by the server.
@param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a single argument: the error returned from the server.
*/
- (NSURLSessionTask *)authenticateUsingOAuthWithURLString:(NSString *)URLString
parameters:(NSDictionary *)parameters
success:(void (^)(AFOAuthCredential *credential))success
failure:(void (^)(NSError *error))failure;

@end

NS_ASSUME_NONNULL_END
Loading

0 comments on commit 2aa4ba7

Please sign in to comment.