Package com.coachconnect.auth
Class OAuthHelper
java.lang.Object
com.coachconnect.auth.OAuthHelper
Helper class for OAuth-related operations.
-
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor for production use.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). -
Method Summary
Modifier and TypeMethodDescriptionstatic com.google.api.client.auth.oauth2.TokenResponseexchangeCodeForToken(String code) Exchanges an authorization code for a token response.com.google.api.client.auth.oauth2.TokenResponseExchanges an authorization code for a token response (instance method).static StringGets the Google OAuth authorization URL.Gets the Google OAuth authorization URL (instance method).
-
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 instancehttpTransport- The HTTP transport to usejsonFactory- 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 occursNullPointerException- If the authorization code is null
-
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
Gets the Google OAuth authorization URL.- Returns:
- The authorisation URL
-