@@ -46,7 +46,11 @@ SecureNative can automatically load your config from *securenative.ini* file or
4646from securenative.securenative import SecureNative
4747
4848
49+ # 1. Config file path is given by environment variable
4950securenative = SecureNative.init()
51+
52+ # 2. Config file path is specified directly
53+ securenative = SecureNative.init(' path/to/securenative.ini' )
5054```
5155### Option 2: Initialize via API Key
5256
@@ -88,18 +92,8 @@ from securenative.models.user_traits import UserTraits
8892
8993securenative = SecureNative.get_instance()
9094
91- context = SecureNative.context_builder().\
92- with_ip(" 127.0.0.1" ).\
93- with_client_token(" SECURED_CLIENT_TOKEN" ).\
94- with_headers({" user-agent" , " Mozilla/5.0 (iPad; U; CPU OS 3_2_1 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Mobile/7B405" }).\
95- build()
96-
97- event_options = EventOptionsBuilder(EventTypes.LOG_IN ).\
98- with_user_id(" 1234" ).\
99- with_user_traits(UserTraits(
" Your Name" ,
" [email protected] " ,
" +1234567890" )).\
100- with_context(context).\
101- with_properties({" prop1" : " CUSTOM_PARAM_VALUE" , " prop2" : True , " prop3" : 3 }).\
102- build()
95+ context = SecureNative.context_builder().with_ip(" 127.0.0.1" ).with_client_token(" SECURED_CLIENT_TOKEN" ).with_headers({" user-agent" , " Mozilla/5.0 (iPad; U; CPU OS 3_2_1 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Mobile/7B405" }).build()
96+ event_options
= EventOptionsBuilder(EventTypes.
LOG_IN ).with_user_id(
" 1234" ).with_user_traits(UserTraits(
" Your Name" ,
" [email protected] " ,
" +1234567890" )).with_context(context).with_properties({
" prop1" :
" CUSTOM_PARAM_VALUE" ,
" prop2" :
True ,
" prop3" :
3 }).build()
10397
10498securenative.track(event_options)
10599 ```
@@ -115,14 +109,9 @@ from securenative.models.user_traits import UserTraits
115109
116110def track (request ):
117111 securenative = SecureNative.get_instance()
118- context = SecureNative.context_builder().from_http_request(request).build()
119112
120- event_options = EventOptionsBuilder(EventTypes.LOG_IN ).\
121- with_user_id(" 1234" ).\
122- with_user_traits(UserTraits(
" Your Name" ,
" [email protected] " ,
" +1234567890" )).\
123- with_context(context).\
124- with_properties({" prop1" : " CUSTOM_PARAM_VALUE" , " prop2" : True , " prop3" : 3 }).\
125- build()
113+ context = SecureNative.context_builder().from_http_request(request).build()
114+ event_options
= EventOptionsBuilder(EventTypes.
LOG_IN ).with_user_id(
" 1234" ).with_user_traits(UserTraits(
" Your Name" ,
" [email protected] " ,
" +1234567890" )).with_context(context).with_properties({
" prop1" :
" CUSTOM_PARAM_VALUE" ,
" prop2" :
True ,
" prop3" :
3 }).build()
126115
127116 securenative.track(event_options)
128117```
@@ -142,12 +131,7 @@ def track(request):
142131 securenative = SecureNative.get_instance()
143132 context = SecureNative.context_builder().from_http_request(request).build()
144133
145- event_options = EventOptionsBuilder(EventTypes.LOG_IN ).\
146- with_user_id(" 1234" ).\
147- with_user_traits(UserTraits(
" Your Name" ,
" [email protected] " ,
" +1234567890" )).\
148- with_context(context).\
149- with_properties({" prop1" : " CUSTOM_PARAM_VALUE" , " prop2" : True , " prop3" : 3 }).\
150- build()
134+ event_options
= EventOptionsBuilder(EventTypes.
LOG_IN ).with_user_id(
" 1234" ).with_user_traits(UserTraits(
" Your Name" ,
" [email protected] " ,
" +1234567890" )).with_context(context).with_properties({
" prop1" :
" CUSTOM_PARAM_VALUE" ,
" prop2" :
True ,
" prop3" :
3 }).build()
151135
152136 verify_result = securenative.verify(event_options)
153137 verify_result.risk_level # Low, Medium, High
0 commit comments