0

On VS2019, when using this OneDrive sample with UWP from Microsoft, I am getting the following error. An online search shows some relevant links (such as this or this or this) but their context are different (as they are using web apps or Python etc.):

AADSTS50011: The reply URL specified in the request does not match the reply URLs configured for the application: '55dbdbc9-xxxxxxxxxxxxx-a24'

I have followed the sample's instructions for Registering and Configuring the app where Redirect URI I have selected is Public client (mobile & desktop), and have set it's value to https://login.microsoftonline.com/common/oauth2/nativeclient

Question: What I may be doing wrong, and how can we resolve the issue?

UPDATE:

Error occurs at line FolderLoaded?.Invoke(this, EventArgs.Empty); of the method shown below. This is line 180 of file OneDriveList.xaml.cs in the sample. And it is not the error OperationCanceledException since error goes to the second catch statement.

private async Task LoadFolderAsync(string id = null)
{
    // Cancel any previous operation
    _cancellationTokenSource?.Cancel();
    _cancellationTokenSource = new CancellationTokenSource();

    // Check if session is set
    if (AuthenticationService == null) throw new InvalidOperationException($"No {nameof(AuthenticationService)} has been specified");

    // Keep a local copy of the token because the source can change while executing this function
    var token = _cancellationTokenSource.Token;

    // Add an option to the REST API in order to get thumbnails for each file
    // https://learn.microsoft.com/en-us/onedrive/developer/rest-api/api/driveitem_list_thumbnails
    var options = new[]
    {
        new QueryOption("$expand", "thumbnails"),
    };

    // Create the graph request builder for the drive
    IDriveRequestBuilder driveRequest = AuthenticationService.GraphClient.Me.Drive;

    // If folder id is null, the request refers to the root folder
    IDriveItemRequestBuilder driveItemsRequest;
    if (id == null)
    {
        driveItemsRequest = driveRequest.Root;
    }
    else
    {
        driveItemsRequest = driveRequest.Items[id];
    }

    // Raise the loading event
    FolderLoading?.Invoke(this, EventArgs.Empty);
    try
    {
        try
        {
            // Make a API request loading 50 items per time
            var page = await driveItemsRequest.Children.Request(options).Top(50).GetAsync(token);
            token.ThrowIfCancellationRequested();

            // Load each page
            await LoadGridItemsAsync(page, token);
            token.ThrowIfCancellationRequested();
        }
        finally
        {
            // Raise the loaded event
            FolderLoaded?.Invoke(this, EventArgs.Empty);
        }
    }
    catch (OperationCanceledException)
    { }
    catch (Exception ex)
    {
        // Raise the error event
        LoadingError?.Invoke(this, ex);
    }
}
nam
  • 21,967
  • 37
  • 158
  • 332
  • I had same issue recently at my company. Turns out I didn't register my phone number so when trying to login the UWP did not have a phone number to call for verification. – jdweng Jun 26 '20 at 17:02
  • @PatrickMcvay Your suggested link did not help. Probably because it's 5 year old and a lot has changed since than in the area of `Microsoft Identity Platform`, `Microsoft Graph API's` etc. `VS2019` does not assign the URI. We do it manually for UWP as explained in step 3 of [this current Microsoft Tutorial](https://learn.microsoft.com/en-us/graph/tutorials/uwp?tutorial-step=2). – nam Jun 26 '20 at 17:10
  • @jdweng Where do they ask for registering the phone number. When I login they do not ask for a phone number. It's an Azure account through Microsoft Visual Studio Enterprise subscription. How do you register a phone number? – nam Jun 26 '20 at 17:15
  • I had to go to my company setup page. I found a document at my company website called "0365 Outlook & Mobility Frequently Asked Questions". I still have it at my computer right now.. – jdweng Jun 26 '20 at 19:00
  • I was getting same login window as you. After entering password correctly I was not allowed access to my email. Apparently there is a secondary verification where the server calls my phone and I have to answer before getting access to email. I suspect MVS is doing similar secondary checking. – jdweng Jun 27 '20 at 00:43
  • @jdweng I'm using Azure AD out of the box. I tried with another login (this time personal MS Account) and it did ask for phone text verification which I provided. This time I registered the app with the directory (tenant) inside the Azure subscription associated with this MS Account. But still the exact same error. I wonder if it has something to do with the sample itself. I was wondering if you would have time to try the sample (linked in the above post) and let me know the outcome? I appreciate your suggestions. – nam Jun 27 '20 at 13:37
  • When I fixed my issue I had to do it from work inside company network. I couldn't get to the website to add my phone number from outside the company network. You need to get the webpage for updating your account and add the phone number. Maybe you are register twice and getting the error due to the duplication. MS is probably for security purposes only allowing one phone number to be registered. Try a different phone number and see if it works. – jdweng Jun 27 '20 at 14:17
  • 1
    Add `urn:ietf:wg:oauth:2.0:oob` as an additional redirect URI and try again – Kalyan Krishna Jun 28 '20 at 10:57
  • @KalyanKrishna Your suggestion worked (thank you) for another sample `Calendar UWP` from MS Graph team. In that sample, I was getting the exact same error posted above. I've not tried your suggestion with the above linked `OneDrive Sample with UWP` yet but I'm almost certain it would work there as well. Will update you once I tried there. – nam Jun 28 '20 at 21:32

0 Answers0