2016-07-29 126 views
0

我正在使用One drive IOS SDK。我创建了一个应用程序ID。它的工作完成,但是当我从应用程序/自己的应用程序登录一个驱动器时,它显示了此消息:OneDrive IOS SDK,错误:很抱歉,但我们在登录时遇到问题,它的错误请求

对不起,但我们在登录时遇到问题,它的请求不正确。

对于OneDrive应用程序,我使用了github链接:https://github.com/OneDrive/onedrive-sdk-ios

首先,我将OneDrive SDK窗格添加到我的项目中。那么,这个功能添加到应用程序委托,

-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. 

[ODClient setMicrosoftAccountAppId:@" - - - - " scopes:@[@"onedrive.appfolder"] ]; 

return YES; 

}

,当我运行这个程序,我的设备,然后我发现了这个错误。

我们无法完成您的请求 Microsoft帐户遇到技术问题。请稍后再试。

其他技术信息:

AADSTS5:回复addess'um:IETF:WG ...”指定的请求不是有效的URL。允许的方案: 'HTTP,HTTPS'

回答

1

@Satyam

能否请您分享您的代码,这样我就可以得到更好的主意。

在这里你去: 代码是迅速,但你可以很容易地转换成Objective C的

作用域: offline_access,onedrive.readonly,onedrive.readwrite,onedrive.appfolder把按您的要求( https://dev.onedrive.com/auth/msa_oauth.htm#authentication-scopes

夫特:

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)") 
     } 
    } 
} 

目标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)

+0

你有足够的代表处,现在要发表评论,请不要使用应答节本。谢谢。 –

+0

@dan对不起,谢谢你的建议:) – iPhoneDev

+0

@iPhoneDev感谢您的回复,我在Swift上试过了您的代码,但是我收到了错误。我们需要在启动时声明odClient,但我不知道它是哪种类型的odClient,也是在getUserDetails方法中odClient给我使用未解析标识符'odClient'的错误。 &在应用程序委托方法它将是返回类型,但是当我返回true时,它会显示白色屏幕。请帮助我进入这个,我是新的迅速:) –