authorizationGrantType cannot be null in Spring Security 5 OAuth Client and Spring Boot 2.0

后端 未结 3 437
孤城傲影
孤城傲影 2020-12-31 13:18

I followed the Spring Security 5.0 official reference documentation and sample codes oauth2login to setup OAuth2/OIDC authentication in my project, but it failed and I got t

相关标签:
3条回答
  • 2020-12-31 13:59

    redirect-uri-template -> redirect-uri it works SpringBoot 2.2.0.RELEASE

    but it works spring 2.1.x with redirect-uri-template

    0 讨论(0)
  • 2020-12-31 14:02

    use redirect-uri instead of redirect-uri-template if use SpringBoot v2.2.1 RELEASE

    0 讨论(0)
  • 2020-12-31 14:09

    To elaborate on OP's update above, the properties you need to include in your application.yaml to resolve the original error are as shown below, in this case for Azure AD (note this ONLY works with Spring Security 5, NOT Spring Security OAuth2 2.x whose functionality is being merged directly into Spring Security 5):

    spring:
      security:
        oauth2:
          client:
            registration:
              microsoft:
                client-id: a935ba7b-6aa4-4b0c-9e84-04f9acaa477b
                client-secret: redacted
                authorization-grant-type: authorization_code
                redirect-uri-template: '{baseUrl}/login/oauth2/code/{registrationId}'
                scope: User.Read
                client-name: Microsoft
                client-alias: microsoft
            provider:
              microsoft:
                authorization-uri: https://login.microsoftonline.com/common/oauth2/authorize?resource=https://graph.microsoft.com/
                token-uri: https://login.microsoftonline.com/common/oauth2/token
                user-info-uri: https://graph.microsoft.com/v1.0/me
                user-name-attribute: sub
                jwk-set-uri: https://login.microsoftonline.com/common/discovery/keys
    
    0 讨论(0)
提交回复
热议问题