@@ -141,9 +141,7 @@ import os
141141
142142
143143with Glean(
144- security = models.Security(
145- api_token = os.getenv(" GLEAN_API_TOKEN" , " " ),
146- ),
144+ api_token = os.getenv(" GLEAN_API_TOKEN" , " " ),
147145) as g_client:
148146
149147 res = g_client.client.chat.create(messages = [
@@ -172,9 +170,7 @@ import os
172170async def main ():
173171
174172 async with Glean(
175- security = models.Security(
176- api_token = os.getenv(" GLEAN_API_TOKEN" , " " ),
177- ),
173+ api_token = os.getenv(" GLEAN_API_TOKEN" , " " ),
178174 ) as g_client:
179175
180176 res = await g_client.client.chat.create_async(messages = [
@@ -202,9 +198,7 @@ import os
202198
203199
204200with Glean(
205- security = models.Security(
206- api_token = os.getenv(" GLEAN_API_TOKEN" , " " ),
207- ),
201+ api_token = os.getenv(" GLEAN_API_TOKEN" , " " ),
208202) as g_client:
209203
210204 res = g_client.client.chat.create_stream(messages = [
@@ -233,9 +227,7 @@ import os
233227async def main ():
234228
235229 async with Glean(
236- security = models.Security(
237- api_token = os.getenv(" GLEAN_API_TOKEN" , " " ),
238- ),
230+ api_token = os.getenv(" GLEAN_API_TOKEN" , " " ),
239231 ) as g_client:
240232
241233 res = await g_client.client.chat.create_stream_async(messages = [
@@ -260,24 +252,21 @@ asyncio.run(main())
260252
261253### Per-Client Security Schemes
262254
263- This SDK supports the following security schemes globally:
255+ This SDK supports the following security scheme globally:
264256
265- | Name | Type | Scheme | Environment Variable |
266- | ------------- | ------ | ----------- | -------------------- |
267- | ` api_token ` | http | HTTP Bearer | ` GLEAN_API_TOKEN ` |
268- | ` cookie_auth ` | apiKey | API key | ` GLEAN_COOKIE_AUTH ` |
257+ | Name | Type | Scheme | Environment Variable |
258+ | ----------- | ---- | ----------- | -------------------- |
259+ | ` api_token ` | http | HTTP Bearer | ` GLEAN_API_TOKEN ` |
269260
270- You can set the security parameters through the ` security ` optional parameter when initializing the SDK client instance. The selected scheme will be used by default to authenticate with the API for all operations that support it . For example:
261+ To authenticate with the API the ` api_token ` parameter must be set when initializing the SDK client instance. For example:
271262``` python
272263from glean import Glean, models
273264from glean.utils import parse_datetime
274265import os
275266
276267
277268with Glean(
278- security = models.Security(
279- api_token = os.getenv(" GLEAN_API_TOKEN" , " " ),
280- ),
269+ api_token = os.getenv(" GLEAN_API_TOKEN" , " " ),
281270) as g_client:
282271
283272 g_client.client.activity.report(events = [
@@ -561,9 +550,7 @@ import os
561550
562551
563552with Glean(
564- security = models.Security(
565- api_token = os.getenv(" GLEAN_API_TOKEN" , " " ),
566- ),
553+ api_token = os.getenv(" GLEAN_API_TOKEN" , " " ),
567554) as g_client:
568555
569556 g_client.client.activity.report(events = [
@@ -605,9 +592,7 @@ import os
605592
606593with Glean(
607594 retry_config = RetryConfig(" backoff" , BackoffStrategy(1 , 50 , 1.1 , 100 ), False ),
608- security = models.Security(
609- api_token = os.getenv(" GLEAN_API_TOKEN" , " " ),
610- ),
595+ api_token = os.getenv(" GLEAN_API_TOKEN" , " " ),
611596) as g_client:
612597
613598 g_client.client.activity.report(events = [
@@ -745,9 +730,7 @@ import os
745730
746731with Glean(
747732 instance = " <value>"
748- security = models.Security(
749- api_token = os.getenv(" GLEAN_API_TOKEN" , " " ),
750- ),
733+ api_token = os.getenv(" GLEAN_API_TOKEN" , " " ),
751734) as g_client:
752735
753736 g_client.client.activity.report(events = [
@@ -790,9 +773,7 @@ import os
790773
791774with Glean(
792775 server_url = " https://instance-name-be.glean.com" ,
793- security = models.Security(
794- api_token = os.getenv(" GLEAN_API_TOKEN" , " " ),
795- ),
776+ api_token = os.getenv(" GLEAN_API_TOKEN" , " " ),
796777) as g_client:
797778
798779 g_client.client.activity.report(events = [
@@ -914,14 +895,12 @@ The `Glean` class implements the context manager protocol and registers a finali
914895[ context-manager ] : https://docs.python.org/3/reference/datamodel.html#context-managers
915896
916897``` python
917- from glean import Glean, models
898+ from glean import Glean
918899import os
919900def main ():
920901
921902 with Glean(
922- security = models.Security(
923- api_token = os.getenv(" GLEAN_API_TOKEN" , " " ),
924- ),
903+ api_token = os.getenv(" GLEAN_API_TOKEN" , " " ),
925904 ) as g_client:
926905 # Rest of application here...
927906
@@ -930,9 +909,7 @@ def main():
930909async def amain ():
931910
932911 async with Glean(
933- security = models.Security(
934- api_token = os.getenv(" GLEAN_API_TOKEN" , " " ),
935- ),
912+ api_token = os.getenv(" GLEAN_API_TOKEN" , " " ),
936913 ) as g_client:
937914 # Rest of application here...
938915```
0 commit comments