2016-07-29 123 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時,它會顯示白色屏幕。請幫助我進入這個,我是新的迅速:) –