Client Credentials authorization with Azure Active directory and Swagger Unicorn Meta Zoo #1: Why another podcast? Announcing the arrival of Valued Associate #679: Cesar Manara Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Invoking Azure API with Swagger UI, fails on CORS preflight requestazure active directory & postmanHow to consume Azure REST API App with Azure Active Directory authorization OnASP.NET Core CORS WebAPI: no Access-Control-Allow-Origin headerGetting Azure active directory token javascriptSwagger UI - Oauth password flow, retrieve and add token to authorized requestsAzure Active Directory Getting code 403 with Client Credentials GrantAzure Active Directory Client Credential FlowAzure Function authentication using Azure Active DirectoryAuthenticate to Azure Log Analytics Api using OAuth2.0 Client credentialsAzure AD reply URLS and Client Credential Grant flow

Married in secret, can marital status in passport be changed at a later date?

What is the purpose of the side handle on a hand ("eggbeater") drill?

When does Bran Stark remember Jamie pushing him?

Can gravitational waves pass through a black hole?

Why did Israel vote against lifting the American embargo on Cuba?

When speaking, how do you change your mind mid-sentence?

What does the black goddess statue do and what is it?

Co-worker works way more than he should

Preserving file and folder permissions with rsync

Where/What are Arya's scars from?

Was Objective-C really a hindrance to Apple software development?

Is it OK if I do not take the receipt in Germany?

Why doesn't the university give past final exams' answers?

Are these square matrices always diagonalisable?

How can I wire a 9-position switch so that each position turns on one more LED than the one before?

My admission is revoked after accepting the admission offer

How would you suggest I follow up with coworkers about our deadline that's today?

What were wait-states, and why was it only an issue for PCs?

false 'Security alert' from Google - every login generates mails from 'no-reply@accounts.google.com'

Is it accepted to use working hours to read general interest books?

Why I cannot instantiate a class whose constructor is private in a friend class?

Is there an efficient way for synchronising audio events real-time with LEDs using an MCU?

Like totally amazing interchangeable sister outfit accessory swapping or whatever

What *exactly* is electrical current, voltage, and resistance?



Client Credentials authorization with Azure Active directory and Swagger



Unicorn Meta Zoo #1: Why another podcast?
Announcing the arrival of Valued Associate #679: Cesar Manara
Data science time! April 2019 and salary with experience
The Ask Question Wizard is Live!Invoking Azure API with Swagger UI, fails on CORS preflight requestazure active directory & postmanHow to consume Azure REST API App with Azure Active Directory authorization OnASP.NET Core CORS WebAPI: no Access-Control-Allow-Origin headerGetting Azure active directory token javascriptSwagger UI - Oauth password flow, retrieve and add token to authorized requestsAzure Active Directory Getting code 403 with Client Credentials GrantAzure Active Directory Client Credential FlowAzure Function authentication using Azure Active DirectoryAuthenticate to Azure Log Analytics Api using OAuth2.0 Client credentialsAzure AD reply URLS and Client Credential Grant flow



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








1















Need to get the authorization token to access my app running on localhost. I query the AAD token endpoint for the token from the Swagger OAuth2 client in UseSwaggerUi3. I get the CORS error that endpoint is not allowing the cross origin requests from my localhost. How can I fix this?



[Edit]
I'm able to get the token if I send a POST request to the same endpoint using Fiddler.










share|improve this question
























  • enable-cors.org/server.html

    – Helen
    Jan 24 at 8:06

















1















Need to get the authorization token to access my app running on localhost. I query the AAD token endpoint for the token from the Swagger OAuth2 client in UseSwaggerUi3. I get the CORS error that endpoint is not allowing the cross origin requests from my localhost. How can I fix this?



[Edit]
I'm able to get the token if I send a POST request to the same endpoint using Fiddler.










share|improve this question
























  • enable-cors.org/server.html

    – Helen
    Jan 24 at 8:06













1












1








1








Need to get the authorization token to access my app running on localhost. I query the AAD token endpoint for the token from the Swagger OAuth2 client in UseSwaggerUi3. I get the CORS error that endpoint is not allowing the cross origin requests from my localhost. How can I fix this?



[Edit]
I'm able to get the token if I send a POST request to the same endpoint using Fiddler.










share|improve this question
















Need to get the authorization token to access my app running on localhost. I query the AAD token endpoint for the token from the Swagger OAuth2 client in UseSwaggerUi3. I get the CORS error that endpoint is not allowing the cross origin requests from my localhost. How can I fix this?



[Edit]
I'm able to get the token if I send a POST request to the same endpoint using Fiddler.







azure azure-active-directory swagger swagger-ui nswag






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 24 at 0:48







user3100148

















asked Jan 24 at 0:36









user3100148user3100148

185




185












  • enable-cors.org/server.html

    – Helen
    Jan 24 at 8:06

















  • enable-cors.org/server.html

    – Helen
    Jan 24 at 8:06
















enable-cors.org/server.html

– Helen
Jan 24 at 8:06





enable-cors.org/server.html

– Helen
Jan 24 at 8:06












2 Answers
2






active

oldest

votes


















1














You can't use client credentials flow from the front-end. Firstly because your secret is visible to anyone who sees the page.



Secondly because Azure AD blocks cross origin requests to its token endpoint. (as you saw)



You need to use authorization code or implicit flow with user context. Or build another API which gets the token in the back-end and calls the other API with it.






share|improve this answer






























    -1














    CORS are the cross origin resource, it will allow two different web apps working on 2 different origin to communicate with each other.
    There are two ways to enable cors
    1) go-to azure - web apps - setting column search - cors.
    2) add new cors header as "*", which means it will allow all the urls which are requesting the web app, you also provide specific one url.
    3) save it.
    4) second approach is allow cors header from your code in web config headers.






    share|improve this answer


















    • 1





      The problem here is not CORS. Azure AD token endpoint is returning the error and it cannot be fixed.

      – juunas
      Jan 25 at 15:55











    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54337781%2fclient-credentials-authorization-with-azure-active-directory-and-swagger%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    You can't use client credentials flow from the front-end. Firstly because your secret is visible to anyone who sees the page.



    Secondly because Azure AD blocks cross origin requests to its token endpoint. (as you saw)



    You need to use authorization code or implicit flow with user context. Or build another API which gets the token in the back-end and calls the other API with it.






    share|improve this answer



























      1














      You can't use client credentials flow from the front-end. Firstly because your secret is visible to anyone who sees the page.



      Secondly because Azure AD blocks cross origin requests to its token endpoint. (as you saw)



      You need to use authorization code or implicit flow with user context. Or build another API which gets the token in the back-end and calls the other API with it.






      share|improve this answer

























        1












        1








        1







        You can't use client credentials flow from the front-end. Firstly because your secret is visible to anyone who sees the page.



        Secondly because Azure AD blocks cross origin requests to its token endpoint. (as you saw)



        You need to use authorization code or implicit flow with user context. Or build another API which gets the token in the back-end and calls the other API with it.






        share|improve this answer













        You can't use client credentials flow from the front-end. Firstly because your secret is visible to anyone who sees the page.



        Secondly because Azure AD blocks cross origin requests to its token endpoint. (as you saw)



        You need to use authorization code or implicit flow with user context. Or build another API which gets the token in the back-end and calls the other API with it.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jan 25 at 15:57









        juunasjuunas

        24k35182




        24k35182























            -1














            CORS are the cross origin resource, it will allow two different web apps working on 2 different origin to communicate with each other.
            There are two ways to enable cors
            1) go-to azure - web apps - setting column search - cors.
            2) add new cors header as "*", which means it will allow all the urls which are requesting the web app, you also provide specific one url.
            3) save it.
            4) second approach is allow cors header from your code in web config headers.






            share|improve this answer


















            • 1





              The problem here is not CORS. Azure AD token endpoint is returning the error and it cannot be fixed.

              – juunas
              Jan 25 at 15:55















            -1














            CORS are the cross origin resource, it will allow two different web apps working on 2 different origin to communicate with each other.
            There are two ways to enable cors
            1) go-to azure - web apps - setting column search - cors.
            2) add new cors header as "*", which means it will allow all the urls which are requesting the web app, you also provide specific one url.
            3) save it.
            4) second approach is allow cors header from your code in web config headers.






            share|improve this answer


















            • 1





              The problem here is not CORS. Azure AD token endpoint is returning the error and it cannot be fixed.

              – juunas
              Jan 25 at 15:55













            -1












            -1








            -1







            CORS are the cross origin resource, it will allow two different web apps working on 2 different origin to communicate with each other.
            There are two ways to enable cors
            1) go-to azure - web apps - setting column search - cors.
            2) add new cors header as "*", which means it will allow all the urls which are requesting the web app, you also provide specific one url.
            3) save it.
            4) second approach is allow cors header from your code in web config headers.






            share|improve this answer













            CORS are the cross origin resource, it will allow two different web apps working on 2 different origin to communicate with each other.
            There are two ways to enable cors
            1) go-to azure - web apps - setting column search - cors.
            2) add new cors header as "*", which means it will allow all the urls which are requesting the web app, you also provide specific one url.
            3) save it.
            4) second approach is allow cors header from your code in web config headers.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Jan 24 at 1:48









            Mayuresh JaiswalMayuresh Jaiswal

            143




            143







            • 1





              The problem here is not CORS. Azure AD token endpoint is returning the error and it cannot be fixed.

              – juunas
              Jan 25 at 15:55












            • 1





              The problem here is not CORS. Azure AD token endpoint is returning the error and it cannot be fixed.

              – juunas
              Jan 25 at 15:55







            1




            1





            The problem here is not CORS. Azure AD token endpoint is returning the error and it cannot be fixed.

            – juunas
            Jan 25 at 15:55





            The problem here is not CORS. Azure AD token endpoint is returning the error and it cannot be fixed.

            – juunas
            Jan 25 at 15:55

















            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54337781%2fclient-credentials-authorization-with-azure-active-directory-and-swagger%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Save data to MySQL database using ExtJS and PHP [closed]2019 Community Moderator ElectionHow can I prevent SQL injection in PHP?Which MySQL data type to use for storing boolean valuesPHP: Delete an element from an arrayHow do I connect to a MySQL Database in Python?Should I use the datetime or timestamp data type in MySQL?How to get a list of MySQL user accountsHow Do You Parse and Process HTML/XML in PHP?Reference — What does this symbol mean in PHP?How does PHP 'foreach' actually work?Why shouldn't I use mysql_* functions in PHP?

            Compiling GNU Global with universal-ctags support Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Tags for Emacs: Relationship between etags, ebrowse, cscope, GNU Global and exuberant ctagsVim and Ctags tips and trickscscope or ctags why choose one over the other?scons and ctagsctags cannot open option file “.ctags”Adding tag scopes in universal-ctagsShould I use Universal-ctags?Universal ctags on WindowsHow do I install GNU Global with universal ctags support using Homebrew?Universal ctags with emacsHow to highlight ctags generated by Universal Ctags in Vim?

            Add ONERROR event to image from jsp tldHow to add an image to a JPanel?Saving image from PHP URLHTML img scalingCheck if an image is loaded (no errors) with jQueryHow to force an <img> to take up width, even if the image is not loadedHow do I populate hidden form field with a value set in Spring ControllerStyling Raw elements Generated from JSP tagds with Jquery MobileLimit resizing of images with explicitly set width and height attributeserror TLD use in a jsp fileJsp tld files cannot be resolved