question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bug Report: Oauth2 Redirect Url malformed

See original GitHub issue

I have an a Durable Task Azure function I created in vs2022, using Microsoft.Azure.WebJobs.Extensions.OpenApi v1.3.0 I configured OpenAPI to use OpenApiVersionType.V3. When I try to Authorize the swagger client, I get the prompt asking for the Client Id and Scope I requested, I provide those, it routes me to Microsoft, but the redirectUrl provided to microsoft is wrong:

redirect_uri=http%3A%2F%2Flocalhost%3A5800https%3A%2F%2Flocalhost%3A5800%2Fapi%2Foauth2-redirect.html

It appears to be combining 2 full absolute urls:

http://localhost:5800 + https://localhost:5800/api/oauth2-redirect.html

Why does it do this? Is there some configuration option to fix this, or override this behavior?

My function is decorated with this attribute:

[OpenApiSecurity("function_key", SecuritySchemeType.OAuth2, Flows = typeof(AzureFunctionOauthSecurityFlows),In = OpenApiSecurityLocationType.Header)]

public class AzureFunctionOauthSecurityFlows : OpenApiOAuthFlows
{
   

    public AzureFunctionOauthSecurityFlows()
    {

        var scopesDictionary = new Dictionary<string, string>();
        scopesDictionary.Add("scope here", "");

        Implicit = new OpenApiOAuthFlow()
        {
            AuthorizationUrl = new Uri("https://login.microsoftonline.com/ID_HERE/oauth2/v2.0/authorize"),
            TokenUrl = new Uri("https://login.microsoftonline.com/ID_HERE/oauth2/v2.0/token"),
            Scopes = scopesDictionary
        };

        
    }
}

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
chinaroseszcommented, Jun 15, 2022

Does anyone know when 1.4.0 will be released? I had to go back to the earlier stable version. Is it possible to reference 1.4.0 without it being released first?

1reaction
andrekibacommented, May 4, 2022

it seems also already fixed https://github.com/Azure/azure-functions-openapi-extension/pull/385 but the 1.4.0 is not yet released

Read more comments on GitHub >

github_iconTop Results From Across the Web

OAuth 2.0 server response malformed url
The issue here is that your path is appearing in the URL fragment (i.e. #/path1/path2/path3). The fragment appears at the end of a...
Read more >
Why is my OAuth2 authorization redirects with malformed ...
I am using Box API service in my app with OAuth2 authorization. I am passing my redirect URL to Box Authorization page as...
Read more >
Solved: Receiving a "redirect_uri_mismatch" error when aut...
I'm trying to use OAUTH 2.0 to authenticate/authorize. I'm testing on my local machine, where my application is running and accessible over HTTPS....
Read more >
[Solved] OAuth2 redirect URL query string is malformed ...
Hi ! I am using Implicit authentication flow. ... There is a # instead of a ? in the URL. ... Is it...
Read more >
Cannot get Access Token using Oauth Code Flow
I'm trying to follow the instructions in here: https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-auth-code-flow.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found