Class MagicalAuth

java.lang.Object
com.glideidentity.service.MagicalAuth

public class MagicalAuth extends Object
Client for carrier-based phone number authentication. Provides methods for SIM-based authentication flows including phone number verification and retrieval. Handles OAuth2 token management internally.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a MagicalAuth service with OAuth2 authentication.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Clears the cached token, forcing a new fetch on next request.
    com.glideidentity.core.Types.GetPhoneNumberResponse
    getPhoneNumber(com.glideidentity.core.Types.GetPhoneNumberRequest request)
    Retrieves the phone number using a credential from the frontend.
    com.glideidentity.core.Types.PrepareResponse
    prepare(com.glideidentity.core.Types.PrepareRequest request)
    Prepares an authentication session.
    com.glideidentity.core.Types.ReportInvocationResponse
    reportInvocation(com.glideidentity.core.Types.ReportInvocationRequest request)
    Reports an authentication invocation for metric tracking.
    com.glideidentity.core.Types.VerifyPhoneNumberResponse
    verifyPhoneNumber(com.glideidentity.core.Types.VerifyPhoneNumberRequest request)
    Verifies a phone number using a credential from the frontend.

    Methods inherited from class java.lang.Object

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

    • MagicalAuth

      public MagicalAuth(Config config, Logger.LoggerInterface logger)
      Creates a MagicalAuth service with OAuth2 authentication.
      Parameters:
      config - SDK configuration containing OAuth2 credentials
      logger - Logger instance
  • Method Details

    • prepare

      public com.glideidentity.core.Types.PrepareResponse prepare(com.glideidentity.core.Types.PrepareRequest request) throws Exception
      Prepares an authentication session.
      Parameters:
      request - prepare request parameters
      Returns:
      session information and authentication strategy
      Throws:
      Exception
    • verifyPhoneNumber

      public com.glideidentity.core.Types.VerifyPhoneNumberResponse verifyPhoneNumber(com.glideidentity.core.Types.VerifyPhoneNumberRequest request) throws Exception
      Verifies a phone number using a credential from the frontend.
      Parameters:
      request - verification request with session and credential
      Returns:
      verification result
      Throws:
      Exception
    • getPhoneNumber

      public com.glideidentity.core.Types.GetPhoneNumberResponse getPhoneNumber(com.glideidentity.core.Types.GetPhoneNumberRequest request) throws Exception
      Retrieves the phone number using a credential from the frontend.
      Parameters:
      request - request with session and credential
      Returns:
      the phone number
      Throws:
      Exception
    • reportInvocation

      public com.glideidentity.core.Types.ReportInvocationResponse reportInvocation(com.glideidentity.core.Types.ReportInvocationRequest request) throws Exception
      Reports an authentication invocation for metric tracking. Returns the server response. For fire-and-forget usage, callers can ignore the response:
      
       // Fire-and-forget
       CompletableFuture.runAsync(() -> magicAuth.reportInvocation(request));
      
       // With response
       ReportInvocationResponse result = magicAuth.reportInvocation(request);
       
      Parameters:
      request - request with session_id
      Returns:
      response with success status
      Throws:
      MagicalAuthError - if session_id is missing or request fails
      Exception
    • clearTokenCache

      public void clearTokenCache()
      Clears the cached token, forcing a new fetch on next request.