使用GraphServiceClient

时间:2017-07-18 18:48:47

标签: c# onedrive

我正在尝试使用GraphServiceClient登录,但在尝试期间,我收到以下错误消息: OneDrive报告了以下错误:基于浏览器的身份验证对话框无法完成。原因:找不到服务器或代理。 Error en Sign In 我从样本中得到的代码是:

public static GraphServiceClient GetAuthenticatedClient(){
    if (graphClient == null)            {
        // Create Microsoft Graph client.
        try {
            graphClient = new GraphServiceClient(
            "https://graph.microsoft.com/v1.0",
            new DelegateAuthenticationProvider(
            async (requestMessage) =>
            {
                var token = await GetTokenForUserAsync();
                requestMessage.Headers.Authorization = new 
                AuthenticationHeaderValue("bearer", token); }));
                return graphClient;
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }
        }
        return graphClient;
    }

0 个答案:

没有答案