Reputation: 185
I have a registered a client to access a web service using OAuth2. I know the client id, client secret and grant type and token endpoint. Does OAuth2 expose an endpoint to get the client registration id? If not, is there any other way to obtain the client registration id?
I am trying to use the client registration id to create a Spring Security ClientRegistration object for use in a Spring WebClient. Is there a way to create a OAuth2 enabled WebClient without the registration id?
Upvotes: 3
Views: 9505
Reputation: 601
You can use any identifier of your choice as a client registration id
. For example, you can name it after API your trying to access or Identity Provider name. It is used to get ClientRegistration
from ClientRegistrationRepository.
ClientRegistrations
are loaded automatically from an application.properties
file. Spring auto-configuration looks for properties with the schema spring.security.oauth2.client.registration.[registrationId]
and creates a ClientRegistration
instance within a ClientRegistrationRepository
.
You can refer to the following blog post for more examples of how to create and use ClientRegistration
class: Intro to Spring Security 5 Core Classes.
Upvotes: 2