Package: logup
The LogUp SDK for Python enables Python developers to easily integrate LogUp service in their projects.Getting StartedSign up for LogUpBefore you begin, you need a LogUp account. Please see theGetting startedsection of the developer guide for information about how to create a LogUp account and create your firstgate.Install the SDKInstall the SDK library usingpippipinstalllogupInitialize the LogUp Client Objectid_gate="{your-id-gate}"gate_secret_key="{your-gate-secret-key}"# Create an instance of LogupClient using the default API Versionlogup_client=LogupClient(id_gate,gate_secret_key)# Create an instance of LogupClient specifying the API versionapi_version="v1_1"logup_client_1=LogupClient(id_gate,gate_secret_key,api_version)Now you’re ready to verify the token received. On the redirect page where the user is sent to after the LogUp, get from
the URL those parameters:logupToken: the unique token to verify user identityisNewUser: true if the user is new for your website, false if the user said he has already an account on your website.More about this parameterVerify user identityThis code is how you can verify that thetoken receivedis correct and seewho the user is.logup_token="{very-long-token-received-as-URL-query-parameter}"is_new_user=TrueorFalseiflogup_client.is_logup_verified(logup_token,is_new_user):# user was successfully logged in!# get the subscription objectsubscription=logup_client.subscriptionelse:print("Ops, the user did not log in")SubscriptionWith the subscription object you can get more information about the actor who logged in, as well as access to its saved
DB. A DB is a key-value store of parameters you can associated to your user.Read mode about DB.Read the valuesThis is how a Subscription object is made:subscription.id_subscription# the id of the subscriptionsubscription.id_actor# the id of the actor that access the subscriptionsubscription.is_new_user# true if it is a new user, false otherwiseFor difference explanation between id actor and id subscriptionsee our documentation.Get subscription DB valuesTo read DB values of that subscription.db=subscription.dbprint("idSubscription retrieved: "+subscription.id_subscription)print("With this DB associated: ")print(db)Add / Update DB valuesAdd or update a DB value.data={"key-test":"","second-key-test":1,"third-key-test":True}db=subscription.update_db(data)print("Db values updated: ")print(db)Somelimitationsmay apply to the values you want to add to a DB: read them in ourdocumentation.
When you update or add values, you do not need to give all the previous values, butjust those you need to update / add.
The db in response will have all the values currently stored in the DB.Delete DB valueskeys=["third-key-test"]db=subscription.delete_db_value(keys)print("New db values: ")print(db)Enter an array with one or more strings representing thekeys you want to removefrom the DB. Theresponsewill have
thecurrent dbwithout the removed values.Operate on custom objectIf you want to operate on a subscription that is not the one retrieved during login, you need to create a new
Subscription object withthe subscription id you are looking for.This is an example:id_subscription="sub_XXXXXXXXXXX"subscription=logup_client.subscription_custom(id_subscription)# on subscription now you can perform all the operation mentioned aboveRemember that if you create a custom new subscription,you won’t have the values ofidActorisNewUserSince they are related to the user trying to access your website, and not to a generic loaded subscription.