commit
eb5a22658f
4 changed files with 39 additions and 0 deletions
14
README.md
14
README.md
|
@ -3,3 +3,17 @@ Test OAuth2 Authorization Code Grant process
|
||||||
|
|
||||||
Code is quite minimal done in js with no lib.
|
Code is quite minimal done in js with no lib.
|
||||||
|
|
||||||
|
|
||||||
|
## Running the Demo
|
||||||
|
|
||||||
|
If you don't want to use sws, you can use python 3.
|
||||||
|
|
||||||
|
``` python
|
||||||
|
python server.py
|
||||||
|
```
|
||||||
|
|
||||||
|
## Utility scripts
|
||||||
|
|
||||||
|
Modify `scripts/get_refresh_token` to retrieve a refresh/access token from the CTR API.
|
||||||
|
|
||||||
|
Modify `scripts/test_access_token` to use your access token to query the CTR API.
|
9
scripts/get_refresh_token.sh
Executable file
9
scripts/get_refresh_token.sh
Executable file
|
@ -0,0 +1,9 @@
|
||||||
|
curl -X POST https://visibility.amp.cisco.com/iroh/oauth2/token \
|
||||||
|
--header "Accept: application/json" \
|
||||||
|
--header "Content-Type: application/x-www-form-urlencoded; charset=UTF-8" \
|
||||||
|
--header "User-Agent: ob-http" \
|
||||||
|
--header "Authorization: Basic <BASE64 ENCODING OF CLIENT_ID:CLIENT_SECRET >" \
|
||||||
|
-d "code=<CODE JWT RETURNED FROM CTR>" \
|
||||||
|
-d "redirect_uri=https://localhost:4443/callback" \
|
||||||
|
-d "scope=admin" \
|
||||||
|
-d "grant_type=authorization_code"
|
5
scripts/test_access_token.sh
Executable file
5
scripts/test_access_token.sh
Executable file
|
@ -0,0 +1,5 @@
|
||||||
|
curl -G https://visibility.amp.cisco.com/iroh/profile/whoami \
|
||||||
|
--header "Accept: application/json" \
|
||||||
|
--header "application/json; charset=UTF-8" \
|
||||||
|
--header "User-Agent: ob-http" \
|
||||||
|
--header "Authorization: Bearer <YOUR_ACCESS_TOKEN_HERE>" \
|
11
server.py
Normal file
11
server.py
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
import http.server, ssl
|
||||||
|
|
||||||
|
server_address = ('localhost', 4443)
|
||||||
|
httpd = http.server.HTTPServer(server_address, http.server.SimpleHTTPRequestHandler)
|
||||||
|
httpd.socket = ssl.wrap_socket(httpd.socket,
|
||||||
|
server_side=True,
|
||||||
|
certfile='cert.pem',
|
||||||
|
keyfile='nopasskey.pem',
|
||||||
|
ssl_version=ssl.PROTOCOL_TLS)
|
||||||
|
print("serving demo on port 4443")
|
||||||
|
httpd.serve_forever()
|
Loading…
Reference in a new issue