/** * Constructs an {@code OAuth2AuthenticationToken} using the provided parameters. * * @param principal the user {@code Principal} registered with the OAuth 2.0 Provider * @param authorities the authorities granted to the user * @param authorizedClientRegistrationId the registration identifier of the {@link OAuth2AuthorizedClient Authorized Client} */ public OAuth2AuthenticationToken(OAuth2User principal, Collection<? extends GrantedAuthority> authorities, String authorizedClientRegistrationId) { super(authorities); Assert.notNull(principal, "principal cannot be null"); Assert.hasText(authorizedClientRegistrationId, "authorizedClientRegistrationId cannot be empty"); this.principal = principal; this.authorizedClientRegistrationId = authorizedClientRegistrationId; this.setAuthenticated(true); }
/** * Constructs an {@code OAuth2AuthenticationToken} using the provided parameters. * * @param principal the user {@code Principal} registered with the OAuth 2.0 Provider * @param authorities the authorities granted to the user * @param authorizedClientRegistrationId the registration identifier of the {@link OAuth2AuthorizedClient Authorized Client} */ public OAuth2AuthenticationToken(OAuth2User principal, Collection<? extends GrantedAuthority> authorities, String authorizedClientRegistrationId) { super(authorities); Assert.notNull(principal, "principal cannot be null"); Assert.hasText(authorizedClientRegistrationId, "authorizedClientRegistrationId cannot be empty"); this.principal = principal; this.authorizedClientRegistrationId = authorizedClientRegistrationId; this.setAuthenticated(true); }