Search code examples
c#xamluwpwindows-community-toolkit

Microsoft.Toolkit.Services.OneDrive.OneDriveService Saved Login


I'm using Microsoft.Toolkit.Services 3.0.0 library for connecting to OneDrive.

My code to authenticate user is:

        if(OneDriveService.Instance.Initialize(App.ClientId, 
          new string[] { MicrosoftGraphScope.FilesReadWrite }, null, null))
        {
            if (!await OneDriveService.Instance.LoginAsync())
            {
                throw new Exception("Unable to sign in");
            }

        // Code to access OneDrive here
        }

I'm able to login to my OneDrive account, but the problem is it's asking me to loggin every time I want to access OneDrive, before using this library I'm using Microsoft.OneDriveSDK which don't show any login after user login.


Solution

  • I have used official code sample to test login. But I can not reproduce your issue. In my side, it could save the login info after login success. It will automatically login next time.

    Please refer OneDrive Service and use code sample to test your application id then exclude other issue.

    Update

    If your Visual Studio reinstall your app during debug, you could check project Debug option. Right click your project->Properties->Debug uncheck Uninstall and then re-install... option. You could solve this issue.

    enter image description here