简体   繁体   English

没有任何方法可以在没有用户输入Microsoft.Graph的情况下静默登录

[英]Is there any way to signin silently without user input in Microsoft.Graph

I am working on a UWP app which use Microsoft.Graph APIs. 我正在使用Microsoft.Graph API的UWP应用程序上工作。 Every time i close my app then i need to sign in again using my Hotmail credentials for authorization. 每次我关闭应用程序时,我都需要使用Hotmail凭据再次登录以进行授权。 I implement this code for GetToken: 我为GetToken实现以下代码:

private static async Task<string> GetTokenForUserAsync()
        {
            try
            {
                authResult = await PCA.AcquireTokenSilentAsync(Scopes);
                userToken = authResult.Token;
            }
            catch (Exception)
            {
                if (userToken == null || expiration <= DateTimeOffset.UtcNow.AddMinutes(5))
                {
                    authResult = await PCA.AcquireTokenAsync(Scopes);

                    userToken = authResult.Token;
                    expiration = authResult.ExpiresOn;
                }
            }

            return userToken;
        }

But every time i reopen my app then AcquireTokenSilentAsync() method threw an exception and ultimately i have to go through the sign in process and give my app bunch of permissions. 但是每次我重新打开我的应用程序时,AcquireTokenSilentAsync()方法都会引发异常,最终我必须经历登录过程并赋予我的应用程序一堆权限。 Is there any silent authentication method available which can authorize my app without the signin process. 是否有可用的静默身份验证方法可以在没有登录过程的情况下授权我的应用程序。

You seem to be running into a problem with Hotmail's security features and authentication methods. 您似乎在遇到Hotmail的安全功能和身份验证方法的问题。 While this maybe convenient for you I would just sign in and deal with the hassle as this creates a lot of security issues. 尽管这可能对您来说很方便,但我还是要登录并解决麻烦,因为这会带来很多安全问题。 If someone exploited your program they would be automatically signed in imagine the security risks this could pose for you. 如果有人利用您的程序,他们会被自动登录,想象这可能给您带来安全隐患。 Never sacrifice security for convenience when coding! 编码时,切勿为了方便而牺牲安全性!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM