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:
def for_user(identifier : UserIdentifier) -> SimSwapUserClient:
Parameters:
Parameter | Type | Description |
---|---|---|
identifier | UserIdentifier | An object representing a user (can be a phonenumber, ip address or custom user id) |
UserIdentifier Properties:
Property | Type | Description |
---|---|---|
phoneNumber | string | The phone number of the user. |
ipAddress | number | The IP address of the user. |
userId | string | A custom user identifier. |
Only one of the properties should be provided.
Returns:
SimSwapUserClient
: A client instance for the specified user.
Example:
from glide import GlideClient
def main():
glide = GlideClient()
sim_swap_user_client = glide.sim_swap.for_user({
"phoneNumber": "+555123456789"
})
if __name__ == "__main__":
main()
SimSwapUserClient Reference
The SimSwapUserClient
is used to interact with the SIM Swap service for a specific phone number.
Properties
1. requiresConsent
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 getConsentUrl
to get the consent URL and ask the user to provide consent before calling check
or retrieveDate
.
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:
from glide import GlideClient
def main():
glide = GlideClient()
sim_swap_user_client = glide.sim_swap.for_user({
"phoneNumber": "+555123456789"
})
sim_swap_check_response = sim_swap_user_client.check()
print(sim_swap_check_response)
# Output: { "swapped": True }
if __name__ == "__main__":
main()
2. retrieveDate
Description:
retrieveDate
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 |
---|---|---|
phoneNumber | 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:
from glide import GlideClient
def main():
glide = GlideClient()
sim_swap_user_client = glide.sim_swap.for_user({
"phoneNumber": "+555123456789"
})
sim_swap_date_response = sim_swap_user_client.retrieve_date()
print(sim_swap_date_response)
# Output: { "latestSimChange": "2022-01-01T00:00:00Z" }
if __name__ == "__main__":
main()
3. getConsentUrl
Description:
getConsentUrl
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:
from glide import GlideClient
def main():
glide = GlideClient()
sim_swap_user_client = glide.sim_swap.for_user({
"phoneNumber": "+555123456789"
})
if sim_swap_user_client.requires_consent:
consent_url = sim_swap_user_client.get_consent_url()
print(consent_url)
if __name__ == "__main__":
main()
4. pollAndWaitForSession
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:
from glide import GlideClient
def main():
glide = GlideClient()
sim_swap_user_client = glide.sim_swap.for_user({
"phoneNumber": "+555123456789"
})
if sim_swap_user_client.requires_consent:
consent_url = sim_swap_user_client.get_consent_url()
print(consent_url)
sim_swap_user_client.poll_and_wait_for_session()
# Now you can call check or retrieveDate
if __name__ == "__main__":
main()
Error Handling
Each method in ExampleService
can throw errors under certain conditions. Developers should handle these exceptions as part of their implementation. Common errors include:
InvalidInputError
: Thrown when input parameters do not meet the required format or type.OperationFailedError
: Thrown when an operation cannot be completed successfully due to various issues, such as network problems or service unavailability.
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. |