forked from googleapis/google-auth-library-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsample.py
More file actions
31 lines (23 loc) · 846 Bytes
/
Copy pathsample.py
File metadata and controls
31 lines (23 loc) · 846 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import google.auth
import google.auth.transport.requests
import google.oauth2.id_token
import google.oauth2._id_token_async
import google.auth.transport._aiohttp_requests
import asyncio
import aiohttp
def run_id_token_sync():
req = google.auth.transport.requests.Request()
token = google.oauth2.id_token.fetch_id_token(req, "https://pubsub.googleapis.com")
print(token)
async def async_fetch_id_token():
req = google.auth.transport._aiohttp_requests.Request()
#req.session = aiohttp.ClientSession()
token = await google.oauth2._id_token_async.fetch_id_token(req, "https://pubsub.googleapis.com")
await req.session.close()
print(token)
def run_id_token_async():
loop = asyncio.get_event_loop()
loop.run_until_complete(async_fetch_id_token())
loop.close()
run_id_token_sync()
run_id_token_async()