Skip to content

Commit d2ec703

Browse files
committed
Add Support for authorization tokens read from .splunkrc
1 parent ad5f21e commit d2ec703

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,18 @@ Save the file as **.splunkrc** in the current user's home directory.
112112

113113
Examples are located in the **/splunk-sdk-python/examples** directory. To run the examples at the command line, use the Python interpreter and include any arguments that are required by the example. In the commands below, replace "examplename" with the name of the specific example in the directory that you want to run:
114114

115+
Using username and Password
116+
115117
python examplename.py --username="admin" --password="changeme"
116118

119+
Using Bearer token
120+
121+
python examplename.py --bearerToken=<value>
122+
123+
Using Session key
124+
125+
python examplename.py --sessionKey="<value>"
126+
117127
If you saved your login credentials in the **.splunkrc** file, you can omit those arguments:
118128

119129
python examplename.py

scripts/templates/splunkrc.template

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,7 @@ password=$password
1010
scheme=$scheme
1111
# Your version of Splunk (default: 6.2)
1212
version=$version
13+
# Bearer token for authentication
14+
#bearerToken=<Bearer-token>
15+
# Session key for authentication
16+
#sessionKey=<Session-Key>

utils/__init__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,16 @@ def config(option, opt, value, parser):
6969
'flags': ["--version"],
7070
'default': None,
7171
'help': 'Ignore. Used by JavaScript SDK.'
72+
},
73+
'splunkToken': {
74+
'flags': ["--bearerToken"],
75+
'default': None,
76+
'help': 'Bearer token for authentication'
77+
},
78+
'token': {
79+
'flags': ["--sessionKey"],
80+
'default': None,
81+
'help': 'Session key for authentication'
7282
}
7383
}
7484

0 commit comments

Comments
 (0)