我正在使用 One drive IOS SDK。我已经创建了一个应用程序 ID。它的工作完成但是当我从应用程序/自己的应用程序登录一个驱动器时,它向我显示了这条消息:
Sorry, but we are having trouble signing in, its bad Request.
我使用了 github 链接:https://github.com/OneDrive/onedrive-sdk-ios用于 OneDrive 应用程序。
首先,我将 OneDrive SDK pod 添加到我的项目中。然后,将此功能添加到应用程序委托(delegate),
-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch.
[ODClient setMicrosoftAccountAppId:@" - - - - " scopes:@[@"onedrive.appfolder"] ];
return YES;
当我在我的设备上运行这个应用程序时,我发现了这个错误。
We're unable to complete your request Microsoft account is experiencing technical problems. Please try again later.
其他技术信息:
AADSTS5 : Reply addess'um:ietf:wg...' specified by the request is not a valid URL. Allowed schemes: 'http,https'
最佳答案
@萨蒂亚姆
能否请您分享您的代码,以便我更好地了解。
给你: 代码很快,但您可以轻松转换为 objective-c
范围: offline_access、onedrive.readonly、onedrive.readwrite、onedrive.appfolder 根据您的要求放置 (https://dev.onedrive.com/auth/msa_oauth.htm#authentication-scopes)
swift :
let kMicrosoftApplicationId = "<MicrosoftApplicationId>"
let kMicrosoftRedirectURL = "urn:ietf:wg:oauth:2.0:oob"
let scopesMicroSoft = ["onedrive.readwrite","onedrive.appfolder"]
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
//ONE DRIVE
ODClient.setMicrosoftAccountAppId(kMicrosoftApplicationId, scopes: scopesMicroSoft)
return true
}
ViewController 你想登陆的地方:
你必须在顶部声明ODClient的对象
import OneDriveSDK
var odClient: ODClient!
func oneDriveClick(sender: UIButton){
authenticateUser()
}
func authenticateUser(){
ODClient.clientWithCompletion { (client, error) in
if ((error == nil)){
self.odClient = client
ODClient.setCurrentClient(client)
self.getUserDetails()
}else{
print("Login error :::: \(error)")
}
}
}
func getUserDetails(){
odClient.drive().request().getWithCompletion { (drive, error) -> Void in
if(error == nil){
print("User name : \(drive.owner.user.displayName)")
}
}
}
objective-c :
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[ODClient setMicrosoftAccountAppId: kMicrosoftApplicationId scopes:@[@"onedrive.readwrite",@"onedrive.appfolder"] ];
return YES;
}
ViewController 你想登陆的地方:
.h代码
@property (strong, nonatomic) ODClient *odClient;
.m文件代码
- (void)oneDriveClick
{
[self authenticateUser];
}
- (void)authenticateUser{
[ODClient authenticatedClientWithCompletion:^(ODClient *client, NSError *error){
if (!error){
self.odClient = client;
[ODClient setCurrentClient:client];
[self getUserDetails];
}
else{
NSLog(@"Error Login :%@",error);
}
}];
}
- (void)getUserDetails{
[[[self.odClient drive] request] getWithCompletion:^(ODDrive *drive, NSError *error){
if (!error){
NSLog(@"User name : %@",drive.owner.user.displayName);
}
}];
}
享受 :) (y)
关于ios - OneDrive IOS SDK,错误 : Sorry, 但我们无法登录,这是错误的请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38658668/