Search code examples
azure-active-directorypostmanspring-cloudspring-cloud-azure

Accesing endpoint from browser is working but not from postman


i have a question regarding the testing flow for accesing a resorce(an endpint in a java spring cloud application) secured by Azure Active Directory. So when i am accesing the resource from browser its redirecting me to microsoft page i paste my crdentials and i am loging in sucesfuly and after that i can acces that resource. But if i am trying to do the same with postman so first of all i need to get the acces token. enter image description here

The get response: enter image description here

After i get the acess token i put it in the Authorization header with Bearer in front, but its returning me the html sign form and whats intersting when i am trying to get request my endpoint resource its redirecting to sign in form and this is why its returning the form. The form is send also when i am trying to get request the resorce (200 status code in both cases with or without token)

I am kinda blocked by this and i am tried many things but its just not work

The spring app has just an controller returning the string "Hello" and has an application.properties;

server:
  forward-headers-strategy: native
  port: 9191

spring:
  cloud:
    azure:
      active-directory:
        enabled: true
        profile:
          tenant-id: TENANTID
        credential:
          client-id: CLIENTID
          client-secret: CLIENTSECRET

enter image description here

enter image description here


Solution

  • The problem was that the app was not an spring-boot-starter-oauth2-resource-server but an spring-boot-starter-oauth2-client