-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathagentnovax-api-auth-nodejs-firebase.postman_collection.json
More file actions
139 lines (139 loc) · 3.68 KB
/
agentnovax-api-auth-nodejs-firebase.postman_collection.json
File metadata and controls
139 lines (139 loc) · 3.68 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
{
"info": {
"_postman_id": "cc4c19ae-4b26-4651-9ad1-8bcedcee86a9",
"name": "AgentNovaX API Collection",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
"_exporter_id": "39166996",
"_collection_link": "https://mat888-6619.postman.co/workspace/MAT-Workspace~9dcaa9e6-2d24-46a1-87eb-f6dcb637543d/collection/39166996-cc4c19ae-4b26-4651-9ad1-8bcedcee86a9?action=share&source=collection_link&creator=39166996"
},
"item": [
{
"name": "validate",
"event": [
{
"listen": "test",
"script": {
"exec": [
""
],
"type": "text/javascript",
"packages": {}
}
},
{
"listen": "prerequest",
"script": {
"exec": [
"// Firebase API URL and Credentials\r",
"const firebaseApiUrl = 'https://identitytoolkit.googleapis.com/v1/accounts:signInWithPassword?key=AIzaSyA21-JCAR0J4K5esr4Qf3hSMm0UEqz06fQ';\r",
"\r",
"// Set up the credentials for the sign-in request\r",
"const email = '<your_user>'; // Replace with your user email\r",
"const password = '<your_user>'; // Replace with your user password\r",
"\r",
"// Set up the request payload\r",
"const requestBody = {\r",
" email: email,\r",
" password: password,\r",
" returnSecureToken: true\r",
"};\r",
"\r",
"// Send the request to Firebase Authentication to get the ID token\r",
"pm.sendRequest({\r",
" url: firebaseApiUrl,\r",
" method: 'POST',\r",
" header: {\r",
" 'Content-Type': 'application/json',\r",
" 'Authorization': pm.environment.get('FIREBASE_AUTH_TOKEN')\r",
" },\r",
" body: {\r",
" mode: 'raw',\r",
" raw: JSON.stringify(requestBody)\r",
" }\r",
"}, function (err, res) {\r",
" if (err) {\r",
" // Handle error if authentication fails\r",
" console.error('Error during Firebase sign-in request:', err);\r",
" } else {\r",
" // Parse the response to get the ID token\r",
" const responseJson = res.json();\r",
"\r",
" // Check if ID token is available in response\r",
" if (responseJson.idToken) {\r",
" // Save the ID token as an environment variable\r",
" pm.environment.set('FIREBASE_AUTH_TOKEN', responseJson.idToken);\r",
" console.log('Firebase ID Token:', responseJson.idToken);\r",
" } else {\r",
" // If ID token is not in the response, handle the error\r",
" console.error('No ID token returned:', responseJson);\r",
" }\r",
" }\r",
"});\r",
""
],
"type": "text/javascript",
"packages": {}
}
}
],
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{FIREBASE_AUTH_TOKEN}}",
"type": "string"
}
]
},
"method": "POST",
"header": [],
"url": {
"raw": "http://localhost:3000/validate",
"protocol": "http",
"host": [
"localhost"
],
"port": "3000",
"path": [
"validate"
]
}
},
"response": []
}
],
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{KW_TOKEN}}",
"type": "string"
}
]
},
"event": [
{
"listen": "prerequest",
"script": {
"type": "text/javascript",
"packages": {},
"exec": [
""
]
}
},
{
"listen": "test",
"script": {
"type": "text/javascript",
"packages": {},
"exec": [
""
]
}
}
]
}