swagger azure ad authentication | web api azure ad authentication | Swagger Azure AD Login

แชร์
ฝัง
  • เผยแพร่เมื่อ 20 ต.ค. 2024

ความคิดเห็น • 70

  • @guilhermefaria1285
    @guilhermefaria1285 3 หลายเดือนก่อน

    Great explanation. Which users will have a successful login when trying to acquire the token? All users from your directory, or is a specific permission required?

    • @azureteachnet
      @azureteachnet  2 หลายเดือนก่อน

      Right now, any one who can log on to the directory can access this. If you need any restrication as such, you can use role claims on API. you can do it in other ways too.

  • @TellaTrix
    @TellaTrix 2 ปีที่แล้ว +1

    Wow ! It has lot of configuration. Really informative content.

  • @juliopinedajung9106
    @juliopinedajung9106 ปีที่แล้ว +1

    Thanks for your video.
    Since I have access to swagger securely:
    Is it possible in Swagger to create an End-Point to get the Azure token?
    And then, using this Token, access the App from another App without having to register the second App?
    Otherwise. How could I access this API without having to register my APP with Azure? Maybe using Swagger to get the Token? Is this possible?

  • @shivamacharya
    @shivamacharya 2 ปีที่แล้ว +1

    Perfact explanation. Most awaited video.

    • @azureteachnet
      @azureteachnet  2 ปีที่แล้ว

      Thank you for the feedback. Please subscribe to the channel if you have not subscribed yet.

  • @walkingdadjokes6099
    @walkingdadjokes6099 2 ปีที่แล้ว

    thx for the details. Why must swagger have it's own app registration though? Swagger is within the API app no?

    • @azureteachnet
      @azureteachnet  2 ปีที่แล้ว +2

      Still Swagger is a client which calls API. General Rule of thumb is API and Client should have their own app registrations. More over, App registrations are free 😀. Thank you.

  • @shatvani
    @shatvani ปีที่แล้ว

    I thank you for sharing your knowledge. By the way, is is neccessary to register a new SwaggerClientAppRegistration registration for Swagger in Azure AD? Cannot it be possible somehow to create a Swagger client in the SwaggerAzureADApi registration, please?

    • @azureteachnet
      @azureteachnet  ปีที่แล้ว +1

      Thanks for the feedback. It is recommended to create.

  • @shatvani
    @shatvani ปีที่แล้ว

    Unfortunatelly when I open the Swagger API in Chrome or Edge after I click on Authorize button nothing happens but in the Firefox authorization works but when I want to try out the WeatherForcast endpont it gives me this error: 'The user or administrator has not consented to use the application with ID ... named API. Send an interactive authorization request for this user and resource.' Could you tell me what is the problem, here, please?

    • @azureteachnet
      @azureteachnet  ปีที่แล้ว

      provide admin consent on default directory on your client app registration. It will work.

  • @viksdeeps09
    @viksdeeps09 ปีที่แล้ว

    Can you direct me, how can I do the same in web api .Net Core 6. Both client call and API call will be in same. Long story shot I need Id Token with user roles, without pop-up. Like get the token silent. Your help is much appreciated.

  • @ac0ncernedcitizen
    @ac0ncernedcitizen ปีที่แล้ว

    16:35 this is fine for testing in Swagger, but do you have a video showing how to authenticate a request m2m without any user to manually authenticate?

    • @azureteachnet
      @azureteachnet  ปีที่แล้ว

      M2M - do you mean, you want to authenticate using a client application, rather logging in with user?

    • @ac0ncernedcitizen
      @ac0ncernedcitizen ปีที่แล้ว

      @@azureteachnet yes

  • @Abhishek-yy3xg
    @Abhishek-yy3xg หลายเดือนก่อน

    How to authenticate the generated bearer token without opening the login window after clicking authorize.

  • @ionix2000
    @ionix2000 10 หลายเดือนก่อน

    Your explained very well. Thank you very much! I appreciate it.

    • @azureteachnet
      @azureteachnet  10 หลายเดือนก่อน

      Thanks for your feedback. Please subscribe to the channel if you have not subscribed yet.

  • @onurakmese2129
    @onurakmese2129 ปีที่แล้ว

    Hi I have a question please, why do we need 2 applications ? It's working with one

    • @azureteachnet
      @azureteachnet  ปีที่แล้ว

      Generally when you use APIs, there should be a client application. So need to have both apps. More over, app registrations are free of cost in azure. Please subscribe to the channel if you have not subscribed yet. Thanks.

  • @Kokolino_
    @Kokolino_ 11 หลายเดือนก่อน

    If I create an Azure Entra ID service to generate a bearer token, with a client_id and client_secret. Can I integrate this in the swagger? Because in your approach you are not using the client secret. I need to use the client secret because I'm building a swagger for a client with oauth2 authentication endpoints, and the idea is to generate the bearer token with a client_id client_secret and the scope. Thanks in advance

    • @azureteachnet
      @azureteachnet  11 หลายเดือนก่อน

      I am working on the video for the same as most of others asked. Will post it soon. Thanks

    • @azureteachnet
      @azureteachnet  11 หลายเดือนก่อน

      I hope you have tried different solutions online. Please read below.
      1. Swaggger sends request to the token endpoint with an ajax call using browser's fetch API.
      2. Azure can send the token for client credentials if the request originated from BROWSER, only if the client app is SPA app.
      3. I tried authentication of app registration as SPA, but still it was not working. Later after researching, came to know that, "Origin" header should not be present in the token request. But unfortunately, BROWSER(Chrome/EDGE) by default adds the header.
      4. I tried intercepting Fetch requests from browser and removing the header, but the browser is adding the origin header just before sending the request, so no luck.
      5. The solution is, your configurations will work but you have to run chrome by disabling web security. Then only it will not send "origin" header and azure returns the token.
      6. One other solution is, call your own api endpoint from swagger authorize screen, by configuring your own api url, use publicClientApplication to generate token using client id and secret then return it.
      EVEN SWAGGER HAVE AN OPEN ISSUE RELATED THIS which was opened in Novemeber 2022.
      Please let me know if it helps. Otherwise please wait for the video. Thanks.

    • @Kokolino_
      @Kokolino_ 11 หลายเดือนก่อน

      Hi @@azureteachnet , Thanks for your fast response! Yes, I have tried differents solutions but nothing work. And I think disable web security is not an option because I have to send the swaggerUI to a client, and I can't say to the client to disable the web security on chrome :( . BTW I'll wait for your video to check with details how do you do, thanks!

    • @azureteachnet
      @azureteachnet  11 หลายเดือนก่อน

      @@Kokolino_ If you dont want to go with disable web security option. the other solution is very simple. Instead of relying on microsoft token url for fetching the token. you can add your own endpoint in the api and use the client id and client secret to fetch the token. You have to configure the same endpoint with Swagger in Program.cs
      Unfortunately Video creation taking time as I am too busy personally and professionally.
      I have added a sample solution in my git hub repo.
      github.com/AzureTeachNet/AzureTeachTutorials/tree/NetCoreWebApiAzureADClientCredentials/SwaggerClientCredentials
      I have added 3 screenshots in the same repo for better understanding.
      If this is helpful to you, please subscribe to the channel and share my channel accross in your friend circles.
      Thank you.

    • @azureteachnet
      @azureteachnet  11 หลายเดือนก่อน

      Please note that, you have to configure your azure ad details in appsettings.json and modify code in program.cs. modifiying program.cs is optional.
      After making this change, you can ask your clients to logon with their client id and client secret.

  • @volkerkleffmann3274
    @volkerkleffmann3274 ปีที่แล้ว

    Thank you very much for your video! Really well explained!

    • @azureteachnet
      @azureteachnet  ปีที่แล้ว

      Thank you for the feedback. Please subscribe to the channel if you have not subscribed yet.

  • @aavuong9360
    @aavuong9360 ปีที่แล้ว

    Thank you for the video. Can you configure swagger to call controller that configure with [Authorize(Roles = "Api.ReadWrite")]? Thank you in advance

    • @azureteachnet
      @azureteachnet  ปีที่แล้ว

      You need to authorize the user by login to the swagger. If the user has the role, he should be able to access it.

  • @dancristian3673
    @dancristian3673 ปีที่แล้ว

    can we create an andpoint "login" to get the token and put it in authorize botton to gain access? any link to share? thanks man!

    • @azureteachnet
      @azureteachnet  ปีที่แล้ว

      We can do that way too. You can generate the token separately from Postman or from your own endpoint and paste the token in the text box to login.
      At present the channel did not have the video. May be in future I will create one.
      Please subscribe to the channel if you have not subscribed yet. Thanks.

  • @dancristian3673
    @dancristian3673 ปีที่แล้ว

    just in case... there`s no more uploaded sample project in github you shared here.

    • @azureteachnet
      @azureteachnet  ปีที่แล้ว

      Unfortunately, I did not upload this code. Going forward, will upload all my videos code to git hub. Thanks.

  • @scorpionesp6510
    @scorpionesp6510 7 หลายเดือนก่อน

    Does this work for AzureAD B2C?

  • @M_Oussama89
    @M_Oussama89 9 หลายเดือนก่อน

    Thanks I like it but project not exist in GitHub link and how we can have a logout end point ?

    • @azureteachnet
      @azureteachnet  9 หลายเดือนก่อน

      On Swagger Authentication popup itself you will see log out button. If you are talking about API, logging out is not responsibility of API. It is responsiblity of Client Application(Angular or react or others).

    • @M_Oussama89
      @M_Oussama89 9 หลายเดือนก่อน

      ​@@azureteachnetThanks for the answer. Yes I know about the logout swagger button but exactly like you said I'm speaking about calling the Login and Logout API endpoint from an angular client app ?

    • @azureteachnet
      @azureteachnet  9 หลายเดือนก่อน

      @@M_Oussama89 for logout, you have to redirect the user to azure ad. refer this video - th-cam.com/video/98T1CumHofI/w-d-xo.html . If this video is helpful to you please subscribe to the channel.

  • @touchtbo
    @touchtbo ปีที่แล้ว

    Can I use JavaScript to access this API?

  • @drouxn3383
    @drouxn3383 ปีที่แล้ว

    Do you have something similar on swagger azure ad b2c authentication? I tried to apply this on Azure AD b2c but some steps are different, especially app registration on AD B2C.

    • @azureteachnet
      @azureteachnet  ปีที่แล้ว +1

      I dont have one right now. Will create a video soon. Thanks

  • @_keano
    @_keano 11 หลายเดือนก่อน

    Is there anyway to refresh the token this way?

    • @azureteachnet
      @azureteachnet  11 หลายเดือนก่อน

      We need to pass the refresh token url in the swagger configuration. If possible will make a video for the same. Thank you.

  • @rokka77
    @rokka77 ปีที่แล้ว

    Loved this, great content!

    • @azureteachnet
      @azureteachnet  ปีที่แล้ว

      Thanks for the feedback. Please subscribe to the channel if you have not subscribed yet. There are a lot azure videos in the channel and more to come in future.

  • @kristianaranda
    @kristianaranda 2 ปีที่แล้ว

    Great video and well explained!

  • @SteveNgaiCheeWeng
    @SteveNgaiCheeWeng ปีที่แล้ว

    Hi, can share the source code? Thanks.

    • @azureteachnet
      @azureteachnet  ปีที่แล้ว

      Unfortunately, this code is not available in the repo. Going forward, will push all my video code to repo. Thanks.

  • @stk8115
    @stk8115 11 หลายเดือนก่อน

    Instead of creating an App Registration for Swagger Client, can we reuse the UI Client App registration client code in Swagger Configuration?

    • @azureteachnet
      @azureteachnet  11 หลายเดือนก่อน

      1. An API works in a client and server model.
      2. If you watch the video, we are giving permission to client app registration.
      3. It is recommended to use a separate client app registration for swagger.
      Please subscribe to the channel if you have not subscribed yet.

    • @stk8115
      @stk8115 11 หลายเดือนก่อน

      @@azureteachnet yes i have an Angular UI Client app registered already other than the Api, i want to use UI Client app info instead of creating a new App Registration for SwaggerCleint. let me know if that works

    • @azureteachnet
      @azureteachnet  11 หลายเดือนก่อน

      @@stk8115 That works.

  • @znk0r
    @znk0r ปีที่แล้ว

    Brilliant!

    • @azureteachnet
      @azureteachnet  ปีที่แล้ว

      Thanks for the feedback. Please subscribe to the channel if you have not subscribed yet.

  • @markjosephjaylo5179
    @markjosephjaylo5179 7 หลายเดือนก่อน

    ty

    • @azureteachnet
      @azureteachnet  7 หลายเดือนก่อน

      Thanks for the feedback. please subscribe to the channel if you are not subscribed yet.

  • @AlexanderPoznanski
    @AlexanderPoznanski ปีที่แล้ว

    Thank you!

    • @azureteachnet
      @azureteachnet  ปีที่แล้ว

      Thanks for the feedback. Please subscribe to the channel if you have not subscribed yet. Thanks

  • @serkangunaydin3307
    @serkangunaydin3307 2 ปีที่แล้ว

    Thanks a lot. It works.

    • @azureteachnet
      @azureteachnet  2 ปีที่แล้ว

      Thanks for the feedback. Please subscribe to the channel if you have not subscribed yet. There are more videos in the channel and a lot more to come. Thanks

  • @vivekkaushik9508
    @vivekkaushik9508 2 ปีที่แล้ว

    You should not be exposing your tenent and client information so casually on the internet. Perhaps blur it or remove it during the recording.

    • @azureteachnet
      @azureteachnet  2 ปีที่แล้ว +3

      Thanks for the suggestion. I delete my app registrations frequently and I dont think it is an issue. All my videos uses user login to authenticate (1 or 2 videos has client secret based), Unless the user is in my azure ad tenant, they cannot login and use my account details. Thanks. Please subscribe to the channel if you have not subscribed yet.

  • @prashanthrapalli
    @prashanthrapalli 5 หลายเดือนก่อน

    this is not working

    • @prashanthrapalli
      @prashanthrapalli 5 หลายเดือนก่อน

      Auth error
      Error: Bad Request, error: invalid_grant, description: AADSTS501481: The Code_Verifier does not match the code_challenge supplied in the authorization request. Trace ID: ********* Correlation ID: ******** Timestamp: 2024-05-07 03:55:22Z

    • @prashanthrapalli
      @prashanthrapalli 5 หลายเดือนก่อน

      Auth error
      Error: Bad Request, error: invalid_grant, description: AADSTS501481: The Code_Verifier does not match the code_challenge supplied in the authorization request. Trace ID: ******** Correlation ID: ********* Timestamp: 2024-05-07 03:55:22Z