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.
SimSwapUserClient
s 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:
Parameter | Type | Description |
---|
UserIdentifier Properties:
Property | Type | Description |
---|---|---|
phone_number | string | The phone number of the user. |
ip_address | number | The IP address of the user. |
user_id | string | A 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
1. requires_consent
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:
Parameter | Type | Description |
---|---|---|
checkParams | SimSwapCheckParams | An object containing the check parameters. |
SimSwapCheckParams Properties:
Property | Type | Description |
---|---|---|
phoneNumber | string | Optional - The phone number to check for a SIM swap. |
maxAge | number | Optional - 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:
Property | Type | Description |
---|---|---|
swapped | boolean | Indicates 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:
Parameter | Type | Description |
---|---|---|
params | SimSwapRetrieveDateParams | An object containing the retrieve date parameters. |
SimSwapRetrieveDateParams Properties:
Property | Type | Description |
---|---|---|
phone_number | string | Optional - The phone number to check for a SIM swap. |
Returns:
SimSwapRetrieveDateResponse
: An object containing the date of the last SIM swap.
SimSwapRetrieveDateResponse Properties:
Property | Type | Description |
---|---|---|
latestSimChange | string | The 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())
3. get_consent_url
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
Property | Type | Description |
---|---|---|
session | Session | An optional session object for authentication and authorization. |
Session
This object represents a user session with an access token, expiration time, and associated scopes.
Properties
Property | Type | Description |
---|---|---|
accessToken | string | The access token for the session. |
expiresAt | number | The expiration time of the session. |
scopes | string[] | An array of scopes associated with the session. |