Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix OneDriveGraphApi when use custom redirect url error. #20

Merged
merged 1 commit into from Oct 27, 2019

Conversation

kgamecarter
Copy link
Contributor

Fix issue #18

@KoenZomers KoenZomers self-requested a review October 10, 2019 22:28
@KoenZomers
Copy link
Owner

Thanks for your contribution. I would like to test this first as it really should not be necessary to provide a client secret. Can you provide me with more detailed steps on how to reproduce the issue please?

@kgamecarter
Copy link
Contributor Author

kgamecarter commented Oct 15, 2019

Create new Azure AD application.
image
Add custom redirect url.
image

In ASP.NET Core MVC project.

private static OneDriveGraphApi oneDriveApi = new OneDriveGraphApi("4f205cff-965c-4f5e-b867-f5e27721c2db");

public async Task<IActionResult> AuthOneDrive()
{
    oneDriveApi.AuthenticationRedirectUrl = "https://localhost:44307/Home/ParseToken";
    return Redirect(oneDriveApi.GetAuthenticationUri().AbsoluteUri);
}

public async Task<IActionResult> ParseToken()
{
    var url = Microsoft.AspNetCore.Http.Extensions.UriHelper.GetDisplayUrl(Request);
    var authToken = oneDriveApi.GetAuthorizationTokenFromUrl(url);
    try
    {
        var token = await oneDriveApi.GetAccessToken();
        return RedirectToAction("Index");
    }
    catch(TokenRetrievalFailedException e) // The request body must contain the following parameter: 'client_assertion' or 'client_secret'.
    { }
    return BadRequest();
}

Copy link
Owner

@KoenZomers KoenZomers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice one, thanks!

@KoenZomers KoenZomers merged commit 05d2416 into KoenZomers:master Oct 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants