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

Commit

Permalink
Merge pull request #62 from OneDrive/v1.1.0
Browse files Browse the repository at this point in the history
V1.1.0
  • Loading branch information
aclev authored and Ace Levenberg committed Nov 10, 2015
2 parents 40579c7 + c3d7d86 commit 3b01fa6
Show file tree
Hide file tree
Showing 38 changed files with 959 additions and 260 deletions.
16 changes: 3 additions & 13 deletions Examples/iOSExplorer/iOSExplorer/ODXAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,9 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
// Uncomment the correct call to test with ActiveDirectory or both types of apps.
[ODClient setMicrosoftAccountAppId:@"0000000048160AF8" scopes:@[@"onedrive.readwrite"] ];

//[ODClient setActiveDirectoryAppId:<activeDirectoryId>
// scopes:<acitveDirectoryScopes>
// redirectURL:<activeDirectoryRedirectURL>
// flags:@{"NoThumbnails" : @(YES) }];
//

//[ODClient setMicrosoftAccountAppId:<MSAAppId>
// microsoftAccountScopes:<MSAScopes>
// microsoftAccountFlags:<MSAFlags>
// activeDirectoryAppId:<activeDirectoryId>
// activeDirectoryScopes:<acitveDirectoryScopes
// activeDirectoryRedirectURL:<activeDirectoryRedirectURL>
// activeDirectoryFlags:<activeDirectoryFlags];
//[ODClient setActiveDirectoryAppId:<AAD_APPID>
// redirectURL:<AAD_REDIRECT_URI>
// flags:@{@"NoThumbnails" : @(YES)}];

return YES;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ - (void)signInAction
if (!error){
self.client = client;
[self loadChildren];
self.navigationItem.rightBarButtonItem = self.actions;
dispatch_async(dispatch_get_main_queue(), ^(){
self.navigationItem.rightBarButtonItem = self.actions;
});
}
else{
[self showErrorAlert:error];
Expand All @@ -105,12 +107,12 @@ - (void)signOutAction
self.client = nil;
self.currentItem = nil;
self.title = @"OneDrive";
self.navigationItem.hidesBackButton = YES;
dispatch_async(dispatch_get_main_queue(), ^(){
self.navigationItem.hidesBackButton = YES;
self.navigationItem.rightBarButtonItem = self.signIn;
// Reload from main thread
[self.collectionView reloadData];
});
self.navigationItem.rightBarButtonItem = self.signIn;
}];
}

Expand Down
2 changes: 1 addition & 1 deletion OneDriveSDK.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Pod::Spec.new do |s|

s.name = "OneDriveSDK"
s.version = "1.0.5"
s.version = "1.1.0"
s.summary = "OneDrive iOS SDK"

s.description = <<-DESC
Expand Down
6 changes: 5 additions & 1 deletion OneDriveSDK/Accounts/ODAADServiceInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@

@interface ODAADServiceInfo : ODServiceInfo

- (instancetype)initWithClientId:(NSString *)clientId scopes:(NSArray *)scopes redirectURL:(NSString *)redirectURL flags:(NSDictionary *)flags;
- (instancetype)initWithClientId:(NSString *)clientId
capability:(NSString *)capability
resourceId:(NSString *)resourceId
redirectURL:(NSString *)redirectURL
flags:(NSDictionary *)flags;

@end
34 changes: 28 additions & 6 deletions OneDriveSDK/Accounts/ODAADServiceInfo.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,28 +23,50 @@
#import "ODServiceInfo+Protected.h"
#import "ODAADServiceInfo.h"
#import "ODBusinessAuthProvider.h"
#import "ODAuthConstants.h"

@implementation ODAADServiceInfo

- (instancetype) initWithCoder:(NSCoder *)aDecoder
{
self = [super initWithCoder:aDecoder];
if (self){
//Migrate ApiEndpoint
if (!_apiEndpoint){
//old versions of the SDK only supported /_api/v2.0/me attached to resourceId
_apiEndpoint = [_resourceId stringByAppendingPathComponent:[OD_ACTIVE_DIRECTORY_URL_SUFFIX copy]];
}
}
return self;
}

- (instancetype)initWithClientId:(NSString *)clientId scopes:(NSArray *)scopes redirectURL:(NSString *)redirectURL flags:(NSDictionary *)flags
- (instancetype)initWithClientId:(NSString *)clientId
capability:(NSString *)capability
resourceId:(NSString *)resourceId
redirectURL:(NSString *)redirectURL
flags:(NSDictionary *)flags
{
NSParameterAssert(redirectURL);
self = [super initWithClientId:clientId scopes:scopes flags:flags];

self = [super initWithClientId:clientId scopes:nil flags:flags];
if (self){
_capability = capability;
_redirectURL = redirectURL;
_resourceId = resourceId;
_authorityURL = [OD_ACTIVE_DIRECTORY_AUTH_URL copy];
_discoveryServiceURL = [OD_DISCOVERY_SERVICE_URL copy];
}
return self;
}

- (NSString *)apiEndpoint
- (id <ODAuthProvider>)createAuthProviderWithSession:(id<ODHttpProvider> )session accountStore:(id <ODAccountStore>)accountStore logger:(id <ODLogger>)logger
{
return [self.resourceId stringByAppendingPathComponent:@"_api/v2.0/me/"];
return [[ODBusinessAuthProvider alloc] initWithServiceInfo:self httpProvider:session accountStore:accountStore logger:logger];
}

- (id <ODAuthProvider>)createAuthProviderWithSession:(id<ODHttpProvider> )session accountStore:(id <ODAccountStore>)accountStore logger:(id <ODLogger>)logger
- (ODAccountType)accountType
{
return [[ODBusinessAuthProvider alloc] initWithServiceInfo:self httpProvider:session accountStore:accountStore logger:logger];
return ODADAccount;
}

@end
50 changes: 34 additions & 16 deletions OneDriveSDK/Accounts/ODAppConfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,19 @@
/**
Configuration for the application.
All app information should match the information in your app portal with Microsoft Accounts or Azure Active Directory.
Visit https://dev.onedrive.com/README.htm for more information.
@see https://dev.onedrive.com/README.htm for more information.
*/
@interface ODAppConfiguration : NSObject

/**
Application Id for OneDrive registered with Microsoft Account.
See https://dev.onedrive.com/auth/msa_oauth.htm for registration information.
@see https://dev.onedrive.com/auth/msa_oauth.htm for registration information.
*/
@property (strong, nonatomic) NSString *microsoftAccountAppId;

/**
Scopes to be used for OneDrive registered with Microsoft Account.
See https://dev.onedrive.com/auth/msa_oauth.htm for registration information.
@see https://dev.onedrive.com/auth/msa_oauth.htm for registration information.
*/
@property (strong, nonatomic) NSArray *microsoftAccountScopes;

Expand All @@ -53,60 +53,78 @@
*/
@property (strong, nonatomic) NSDictionary *microsoftAccountFlags;

/**
The API Endpoint for the Micrsoft Account Service (defaults to onedrive)
*/
@property (strong, nonatomic) NSString *microsoftAccountApiEndpoint;

/**
Application Id for OneDrive for Business.
See https://dev.onedrive.com/auth/aad_oauth.htm for registration information.
@see https://dev.onedrive.com/auth/aad_oauth.htm for registration information.
*/
@property (strong, nonatomic) NSString *activeDirectoryAppId;

/**
Redirect URL for OneDrive for Business.
See https://dev.onedrive.com/auth/aad_oauth.htm for registration information.
Warning: This value must be the same as the RedirectURL provided in the Azure Active Directory portal.
@see https://dev.onedrive.com/auth/aad_oauth.htm for registration information.
@warning This value must be the same as the RedirectURL provided in the Azure Active Directory portal.
*/
@property (strong, nonatomic) NSString *activeDirectoryRedirectURL;

/**
Scopes to be used for OneDrive for Business.
See https://dev.onedrive.com/auth/aad_oauth.htm for registration information.
Capability for Active Directory defaults to MyFiles
@see https://dev.onedrive.com/auth/aad_oauth.htm for registration information.
@warning may be nil.
*/
@property (strong, nonatomic) NSString *activeDirectoryCapability;

/**
The resourceId you wish to access.
@warning may be nil.
*/
@property (strong, nonatomic) NSString *activeDirectoryResourceId;

/**
The API Endpoint URL for Active Driectory.
@warning may be nil.
*/
@property (strong, nonatomic) NSArray *activeDirectoryScopes;
@property (strong, nonatomic) NSString *activeDirectoryApiEndpointURL;

/**
Any flags to be passed into the ODClient if the client is a OneDrive for Business account.
See [ODClient serviceFlags].
@see [ODClient serviceFlags].
*/
@property (strong, nonatomic) NSDictionary *activeDirectoryFlags;

/**
The parent view controller to present the Authentication View controller on top of.
Warning: If no ParentAuthController is provided, the default will be the root view controller of the application.
@warning If no ParentAuthController is provided, the default will be the root view controller of the application.
*/
@property (strong, nonatomic) UIViewController *parentAuthController;

/**
The Service Info Provider to be used to discover the correct authentication service.
Warning: If this is nil you must provide an authentication provider.
@warning If this is nil you must provide an authentication provider.
See authProvider.
*/
@property (strong, nonatomic) ODServiceInfoProvider *serviceInfoProvider;

/**
The httpProvider to be used for all network requests.
Warning: This must not be nil.
@warning This must not be nil.
*/
@property (strong, nonatomic) id <ODHttpProvider> httpProvider;

/**
The accountStore to be used for persistent access to the service.
Warning: If this is nil there will be no storage of accounts. Users will have to sign in every time they re-open the application.
@warning If this is nil there will be no storage of accounts. Users will have to sign in every time they re-open the application.
*/
@property (strong, nonatomic) id <ODAccountStore> accountStore;

/**
The Authentication Provider to be used.
Warning: This may be nil, and if it is, there must be an ODServiceInfoProvider to discover the correct authentication provider to use.
See serviceInfoProvider.
@warning This may be nil, and if it is, there must be an ODServiceInfoProvider to discover the correct authentication provider to use.
@see serviceInfoProvider.
*/
@property (strong, nonatomic) id <ODAuthProvider> authProvider;

Expand Down
6 changes: 4 additions & 2 deletions OneDriveSDK/Accounts/ODMSAServiceInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

@interface ODMSAServiceInfo : ODServiceInfo

- (instancetype)initWithClientId:(NSString *)clientId scopes:(NSArray *)scopes flags:(NSDictionary *)flags;

- (instancetype)initWithClientId:(NSString *)clientId
scopes:(NSArray *)scopes
flags:(NSDictionary *)flags
apiEndpoint:(NSString *)apiEndpoint;
@end
29 changes: 23 additions & 6 deletions OneDriveSDK/Accounts/ODMSAServiceInfo.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,34 @@

@implementation ODMSAServiceInfo

- (instancetype)initWithClientId:(NSString *)clientId scopes:(NSArray *)scopes flags:(NSDictionary *)flags
- (instancetype)initWithClientId:(NSString *)clientId
scopes:(NSArray *)scopes
flags:(NSDictionary *)flags
apiEndpoint:(NSString *)apiEndpoint;
{
NSParameterAssert(scopes);

self = [super initWithClientId:clientId scopes:scopes flags:flags];
if (self){
_resourceId = [OD_microsoftAccounnt_ENDPOINT copy];
_redirectURL = [MSARedirectURL copy];
_logoutURL = [MSALogOutURL copy];
_authorityURL = [OD_MICROSOFT_ACCOUNT_AUTH_URL copy];
_tokenURL = [OD_MICROSOFT_ACCOUNT_TOKEN_URL copy];
_apiEndpoint = apiEndpoint;
_redirectURL = [OD_MICROSOFT_ACCOUNT_REDIRECT_URL copy];
_logoutURL = [OD_MICROSOFT_ACCOUNT_LOGOUT_URL copy];
}
return self;
}

- (NSString *)apiEndpoint
- (instancetype)initWithCoder:(NSCoder *)aDecoder
{
return self.resourceId;
self = [super initWithCoder:aDecoder];
if (self){
//Migrate the APIEndpoint from resource Id if this was loaded from an older SDK version
if (!_apiEndpoint){
_apiEndpoint = _resourceId;
}
}
return self;
}

- (NSDictionary *)authRequestParameters
Expand All @@ -56,4 +68,9 @@ - (NSDictionary *)authRequestParameters
return [[ODPersonalAuthProvider alloc] initWithServiceInfo:self httpProvider:session accountStore:accountStore logger:logger];
}

- (ODAccountType)accountType
{
return ODMSAAccount;
}

@end
2 changes: 1 addition & 1 deletion OneDriveSDK/Accounts/ODServiceInfo+Protected.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@
NSString *_discoveryServiceURL;
NSString *_userEmail;
NSString *_apiEndpoint;
NSString *_capability;
NSArray *_scopes;
}


- (instancetype)initWithClientId:(NSString *)clientId scopes:(NSArray *)scopes flags:(NSDictionary *)flags;

- (NSDictionary *)authRequestParameters;
Expand Down
1 change: 1 addition & 0 deletions OneDriveSDK/Accounts/ODServiceInfoProvider.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,5 @@ typedef void(^disambiguationCompletion)(UIViewController *presentedDiscoveryCont
- (void)getServiceInfoWithViewController:(UIViewController *)viewController
appConfiguration:(ODAppConfiguration *)appConfig
completion:(disambiguationCompletion)completionHandler;

@end
Loading

0 comments on commit 3b01fa6

Please sign in to comment.