【发布时间】:2015-03-17 22:56:16
【问题描述】:
我已经添加了公告应用程序并添加了一些项目,现在我想从我的公告列表中获取项目,所以我使用了以下代码
token_Obtained_During_first_time_Login:这是我第一次使用ADAuthenticationContext类的acquireTokenWithResource方法登录时得到的令牌
- (void)getClientList {
NSString *appToken = [[NSUserDefaults standardUserDefaults]
valueForKey:@"token_Obtained_During_first_time_Login"];
NSString* hostName = @"https://myTenant.sharepoint.com/sites/myApp";
OAuthentication *credentials = [[OAuthentication alloc] initWith:appToken];
ListClient *client = [[ListClient alloc]
initWithUrl:hostName
credentials:credentials];
NSURLSessionTask* task = [client getListItems:@"MyAnnouncements"
callback:^(NSMutableArray *listItems, NSError *error) {
if (error==nil) {
NSLog(@"%@",listItems);
}
}];
[task resume];
}
我什至调试了 365 代码,它为我提供了 getListItems 的以下 URL:回调方法
https://myTenant.sharepoint.com/sites/myApp/_api/lists/GetByTitle('MyAnnouncements')/Items
我什至尝试过使用示例代码附带的 getTokenWith 方法
- (void)getAnnouncementList:(void (^)(ListClient *))callback{
NSString* hostName = @"https://myTenant.sharepoint.com";
[self getTokenWith:hostName :true completionHandler:^(NSString *token) {
OAuthentication *credentials = [[OAuthentication alloc] initWith:token];
callback([[ListClient alloc]initWithUrl:hostName credentials:credentials]);
}];
}
但还是没有运气,我得到的列表为零
请指导如何解决这个问题,我什至验证了 Azure 目录中的权限,一切似乎都很好,能够获取一个驱动器、邮件和日历的数据,但列表是我卡住的地方。
每次我调用上面的代码时,我都会得到响应 nil 不确定传递了什么错误,我猜是令牌。
【问题讨论】:
-
initWithUrl:@"yoursharepoint-my.sharepoint.com/personal/user_contoso_com" credentials:credentials];如何在没有硬编码数据的情况下自动获取每个帐户的此链接?
标签: ios sharepoint office365