@@ -110,6 +110,7 @@ This example shows how to use the Splunk Enterprise SDK for JavaScript and Node.
110
110
});
111
111
```
112
112
##### Login with sessionKey
113
+
113
114
``` shell
114
115
# Create a sessionKey
115
116
curl -k -u < username> :< password> < scheme> ://< host> :< port> /services/auth/login -d username=< username> -d password=< password>
@@ -122,7 +123,7 @@ var serviceWithSessionKey = new splunkjs.Service(
122
123
scheme: ' https' ,
123
124
host: ' localhost' ,
124
125
port: ' 8089' ,
125
- sessionKey: ' SESSION_KEY' , // Add your session key
126
+ sessionKey: SESSION_KEY , // Add your sessionKey here
126
127
version: ' 8' ,
127
128
});
128
129
@@ -138,17 +139,20 @@ serviceWithSessionKey.get("search/jobs", { count: 1 }, function (err, res) {
138
139
##### Login with token
139
140
140
141
``` shell
141
- # Enable token authetication from shell
142
+ # ### From shell ####
143
+ # Enable token authetication
142
144
curl -k -u < username> :< password> -X POST < scheme> ://< host> :< port> /services/admin/token-auth/tokens_auth -d disabled=false
143
145
144
- # Enable token authentication from web
145
- Go to settings > Tokens and click on ' Enable Token Authentication '
146
+ # Create a token
147
+ curl -k -u < username > : < password > -X POST < scheme > :// < host > : < port > /services/authorization/tokens ? output_mode=json --data name=admin --data audience=Users --data-urlencode expires_on=+30d
146
148
```
149
+
147
150
``` shell
148
- # Create a token from shell
149
- curl -k -u < username> :< password> -X POST < scheme> ://< host> :< port> /services/authorization/tokens? output_mode=json --data name=admin --data audience=Users --data-urlencode expires_on=+30d
151
+ # ### From web ####
152
+ # Enable token authentication
153
+ Go to settings > Tokens and click on ' Enable Token Authentication'
150
154
151
- # Create a token from web
155
+ # Create a token
152
156
1. Go to settings > Token and click on ' New Token'
153
157
2. Enter the relevant information
154
158
3. Copy the created token and save it somewhere safe.
@@ -161,7 +165,7 @@ var serviceWithBearerToken = new splunkjs.Service(
161
165
scheme: ' https' ,
162
166
host: ' localhost' ,
163
167
port: ' 8089' ,
164
- sessionKey: ' TOKEN' , // Add your token here
168
+ sessionKey: TOKEN , // Add your token here
165
169
version: ' 8' ,
166
170
});
167
171
0 commit comments