OneDrive身份验证后获取用户详细信息

时间:2015-11-03 13:07:13

标签: ios swift onedrive

我正在尝试使用OneDrive API对用户进行身份验证。用户身份验证已成功完成。但是,我还希望在用户通过身份验证后获取用户的电子邮件或姓名。以下是我目前的代码

ODClient.setMicrosoftAccountAppId(ODAppKey, scopes: ["wl.signin", "wl.offline_access", "onedrive.readonly", "onedrive.readwrite", "onedrive.appfolder"])

ODClient.clientWithCompletion({ (client, error) -> Void in
    if(error == nil){
        odClient = client
    }
})

如何在用户通过身份验证后获取登录用户详细信息。请帮忙

提前致谢

2 个答案:

答案 0 :(得分:0)

当您retrieve a drive时,它会返回包含显示名称的所有者对象,但OneDrive API当前不支持电子邮件。 This issue跟踪添加该支持。

答案 1 :(得分:0)

我解决了它:

ODClient.clientWithCompletion({ (client, error) -> Void in
    if(error == nil){
        odClient = client
        self.getUserDetails()
    }
})

func getUserDetails(){
    odClient.drive().request().getWithCompletion { (drive, error) -> Void in
        if(error == nil){
            print("User name : \(drive.owner.user.displayName)")
        }
    }
}

注意:使用OneDrive,只有为帐户设置显示名称才能获取显示名称。

感谢@ginach

相关问题