Class OAuthHelper

java.lang.Object
com.coachconnect.auth.OAuthHelper

public class OAuthHelper extends Object
Helper class for OAuth-related operations.
  • Constructor Details

    • OAuthHelper

      public OAuthHelper(ConfigManager configManager, com.google.api.client.http.HttpTransport httpTransport, com.google.api.client.json.JsonFactory jsonFactory)
      Constructor for dependency injection (primarily used in tests).
      Parameters:
      configManager - The configuration manager instance
      httpTransport - The HTTP transport to use
      jsonFactory - The JSON factory to use
    • OAuthHelper

      public OAuthHelper()
      Default constructor for production use.
  • Method Details

    • exchangeCodeForTokenInstance

      public com.google.api.client.auth.oauth2.TokenResponse exchangeCodeForTokenInstance(String code) throws IOException
      Exchanges an authorization code for a token response (instance method). This method is designed to be testable with dependency injection.
      Parameters:
      code - The authorisation code
      Returns:
      The token response
      Throws:
      IOException - If an error occurs
      NullPointerException - If the authorization code is null
    • getGoogleAuthUrlInstance

      public String getGoogleAuthUrlInstance()
      Gets the Google OAuth authorization URL (instance method). This method is designed to be testable with dependency injection.
      Returns:
      The authorisation URL
    • exchangeCodeForToken

      public static com.google.api.client.auth.oauth2.TokenResponse exchangeCodeForToken(String code) throws IOException
      Exchanges an authorization code for a token response.
      Parameters:
      code - The authorisation code
      Returns:
      The token response
      Throws:
      IOException - If an error occurs
    • getGoogleAuthUrl

      public static String getGoogleAuthUrl()
      Gets the Google OAuth authorization URL.
      Returns:
      The authorisation URL