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
redirect-uri-template -> redirect-uri it works SpringBoot 2.2.0.RELEASE
but it works spring 2.1.x with redirect-uri-template
use redirect-uri instead of redirect-uri-template if use SpringBoot v2.2.1 RELEASE
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