Class OAuth2AuthorizedClient

  • All Implemented Interfaces:
    java.io.Serializable

    public class OAuth2AuthorizedClient
    extends java.lang.Object
    implements java.io.Serializable
    A representation of an OAuth 2.0 "Authorized Client".

    A client is considered "authorized" when the End-User (Resource Owner) has granted authorization to the client to access it's protected resources.

    This class associates the Client to the Access Token granted/authorized by the Resource Owner.

    Since:
    5.0
    See Also:
    ClientRegistration, OAuth2AccessToken, OAuth2RefreshToken, Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      OAuth2AuthorizedClient​(ClientRegistration clientRegistration, java.lang.String principalName, org.springframework.security.oauth2.core.OAuth2AccessToken accessToken)
      Constructs an OAuth2AuthorizedClient using the provided parameters.
      OAuth2AuthorizedClient​(ClientRegistration clientRegistration, java.lang.String principalName, org.springframework.security.oauth2.core.OAuth2AccessToken accessToken, org.springframework.security.oauth2.core.OAuth2RefreshToken refreshToken)
      Constructs an OAuth2AuthorizedClient using the provided parameters.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      org.springframework.security.oauth2.core.OAuth2AccessToken getAccessToken()
      Returns the access token credential granted.
      ClientRegistration getClientRegistration()
      Returns the authorized client's registration.
      java.lang.String getPrincipalName()
      Returns the End-User's Principal name.
      org.springframework.security.oauth2.core.OAuth2RefreshToken getRefreshToken()
      Returns the refresh token credential granted.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • OAuth2AuthorizedClient

        public OAuth2AuthorizedClient​(ClientRegistration clientRegistration,
                                      java.lang.String principalName,
                                      org.springframework.security.oauth2.core.OAuth2AccessToken accessToken)
        Constructs an OAuth2AuthorizedClient using the provided parameters.
        Parameters:
        clientRegistration - the authorized client's registration
        principalName - the name of the End-User Principal (Resource Owner)
        accessToken - the access token credential granted
      • OAuth2AuthorizedClient

        public OAuth2AuthorizedClient​(ClientRegistration clientRegistration,
                                      java.lang.String principalName,
                                      org.springframework.security.oauth2.core.OAuth2AccessToken accessToken,
                                      @Nullable
                                      org.springframework.security.oauth2.core.OAuth2RefreshToken refreshToken)
        Constructs an OAuth2AuthorizedClient using the provided parameters.
        Parameters:
        clientRegistration - the authorized client's registration
        principalName - the name of the End-User Principal (Resource Owner)
        accessToken - the access token credential granted
        refreshToken - the refresh token credential granted
    • Method Detail

      • getPrincipalName

        public java.lang.String getPrincipalName()
        Returns the End-User's Principal name.
        Returns:
        the End-User's Principal name
      • getAccessToken

        public org.springframework.security.oauth2.core.OAuth2AccessToken getAccessToken()
        Returns the access token credential granted.
        Returns:
        the OAuth2AccessToken
      • getRefreshToken

        @Nullable
        public org.springframework.security.oauth2.core.OAuth2RefreshToken getRefreshToken()
        Returns the refresh token credential granted.
        Returns:
        the OAuth2RefreshToken
        Since:
        5.1