Skip to main content
Version: Python

SIM Swap Reference

The SIM Swap client is scoped to a single phone number, so in-order to interact with the SIM Swap service, you need to create a SimSwapUserClient instance for the phone number you want to check.

SimSwapUserClients are creating using the SimSwapClient accessible from the GlideClient instance.

SimSwapClient Reference

Methods

1. forUser

Description: forUser creates a SimSwapUserClient instance for the specified phone number.

Syntax:

async def for_user(phone_number: str = None, ip_address: str = None, user_id: str = None) -> SimSwapUserClient

Parameters:

ParameterTypeDescription

UserIdentifier Properties:

PropertyTypeDescription
phone_numberstringThe phone number of the user.
ip_addressnumberThe IP address of the user.
user_idstringA custom user identifier.

Only one of the properties should be provided.

Returns:

  • SimSwapUserClient: A client instance for the specified user.

Example:

import asyncio
from glide import GlideClient

async def main():
glide = GlideClient()
sim_swap_client = await glide.sim_swap.for_user(
phone_number="+555123456789"
)

if __name__ == "__main__":
asyncio.run(main())

SimSwapUserClient Reference

The SimSwapUserClient is used to interact with the SIM Swap service for a specific phone number.

Properties

A boolean indicating if the user needs to provide consent before checking for a SIM swap. If this is true then you need to call get_consent_url to get the consent URL and ask the user to provide consent before calling check or retrieve_date.

Methods

1. check

Description: check verifies if a SIM swap has occurred for the user's phone number.

Syntax:

def check(checkParams: SimSwapCheckParams = {}, config: ApiConfig = {}) -> SimSwapCheckResponse:

Parameters:

ParameterTypeDescription
checkParamsSimSwapCheckParamsAn object containing the check parameters.

SimSwapCheckParams Properties:

PropertyTypeDescription
phoneNumberstringOptional - The phone number to check for a SIM swap.
maxAgenumberOptional - Maximum age of the SIM swap in hours.

If phoneNumber was provied in the forUser method as the user identifier, it can be omitted here.

Returns:

  • SimSwapCheckResponse: An object containing the SIM swap status.

SimSwapCheckResponse Properties:

PropertyTypeDescription
swappedbooleanIndicates if a SIM swap has occurred up to maxAge hours ago

Example:

import asyncio
from glide import GlideClient

async def main():
glide = GlideClient()
sim_swap_client = await glide.sim_swap.for_user(
phone_number="+555123456789"
)

sim_swap_check_response = await sim_swap_client.check()
print(sim_swap_check_response)
# Output: { "swapped": True }

if __name__ == "__main__":
asyncio.run(main())

2. retrieve_date

Description: retrieve_date retrieves the date of the last SIM swap for the user's phone number.

Syntax:

def retrieve_date(params: SimSwapRetrieveDateParams = {}, config: ApiConfig = {}) -> SimSwapRetrieveDateResponse:

Parameters:

ParameterTypeDescription
paramsSimSwapRetrieveDateParamsAn object containing the retrieve date parameters.

SimSwapRetrieveDateParams Properties:

PropertyTypeDescription
phone_numberstringOptional - The phone number to check for a SIM swap.

Returns:

  • SimSwapRetrieveDateResponse: An object containing the date of the last SIM swap.

SimSwapRetrieveDateResponse Properties:

PropertyTypeDescription
latestSimChangestringThe date of the last SIM swap in ISO 8601 format.

Example:

import asyncio
from glide import GlideClient

async def main():
glide = GlideClient()
sim_swap_client = await glide.sim_swap.for_user(
phone_number="+555123456789"
)

sim_swap_date_response = await sim_swap_client.retrieve_date()
print(sim_swap_date_response)
# Output: { "latestSimChange": "2022-01-01T00:00:00Z" }

if __name__ == "__main__":
asyncio.run(main())

Description: get_consent_url retrieves the URL for the user to provide consent before checking for a SIM swap.

Syntax:

def get_consent_url() -> str:

Returns:

  • string: The URL for the user to provide consent.

Example:

import asyncio
from glide import GlideClient

async def main():
glide = GlideClient()
sim_swap_client = await glide.sim_swap.for_user(
phone_number="+555123456789"
)

if sim_swap_client.requires_consent:
consent_url = sim_swap_client.get_consent_url()
print(consent_url)

if __name__ == "__main__":
asyncio.run(main())

4. poll_and_wait_for_session

Description: pollAndWaitForSession polls the SIM Swap service until the user has provided consent and a session is available. This method should be called after you have retrieved the consent URL and passed it to the user.

Syntax:

def poll_and_wait_for_session() -> None:

Returns:

  • void

Example:

import asyncio
from glide_sdk import GlideClient

async def main():
glide = GlideClient()
sim_swap_client = await glide.sim_swap.for_user(
phone_number="+555123456789"
)

if sim_swap_client.requires_consent:
consent_url = sim_swap_client.get_consent_url()
print(consent_url)
await sim_swap_client.poll_and_wait_for_session()
# Now you can call check or retrieveDate

if __name__ == "__main__":
asyncio.run(main())

Type Definitions

ApiConfig

This object can be sent to most service apis to override the default configuration like the access token used in the request.

Properties

PropertyTypeDescription
sessionSessionAn optional session object for authentication and authorization.

Session

This object represents a user session with an access token, expiration time, and associated scopes.

Properties

PropertyTypeDescription
accessTokenstringThe access token for the session.
expiresAtnumberThe expiration time of the session.
scopesstring[]An array of scopes associated with the session.