From ef818854f6d90bd52b4f2661a48ee19c18eb6a60 Mon Sep 17 00:00:00 2001 From: "Yann Esposito (Yogsototh)" Date: Tue, 23 Apr 2019 12:27:55 +0200 Subject: [PATCH 1/5] gitlab_message --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..d51dc65 --- /dev/null +++ b/README.md @@ -0,0 +1,9 @@ +> This project has two homes. +> It is ok to work in github, still, for a better decentralized web +> please consider contributing (issues, PR, etc...) throught: +> +> https://gitlab.esy.fun/yogsototh/oauth2-client-demo + +--- + + From ec2c30614a9224541fafee45a7c39e3fc5fd8a52 Mon Sep 17 00:00:00 2001 From: Yann Esposito Date: Wed, 26 Jun 2019 17:30:41 +0200 Subject: [PATCH 2/5] Update README.md --- README.md | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index d51dc65..650a78c 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,5 @@ -> This project has two homes. -> It is ok to work in github, still, for a better decentralized web -> please consider contributing (issues, PR, etc...) throught: -> -> https://gitlab.esy.fun/yogsototh/oauth2-client-demo - ---- +Test OAuth2 Authorization Code Grant process +Code is quite minimal done in js with no lib. + From 8c7e622f1d6064cfad4a8b8bdb781ac5666f9379 Mon Sep 17 00:00:00 2001 From: Leland Krych Date: Mon, 2 Mar 2020 21:31:24 -0800 Subject: [PATCH 3/5] add option for python server --- server.py | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 server.py diff --git a/server.py b/server.py new file mode 100644 index 0000000..749be47 --- /dev/null +++ b/server.py @@ -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() \ No newline at end of file From 99a2b736401006df1e2e29425829a0285fded969 Mon Sep 17 00:00:00 2001 From: Leland Krych Date: Mon, 2 Mar 2020 21:36:58 -0800 Subject: [PATCH 4/5] move scripts to scripts folder --- scripts/get_refresh_token.sh | 9 +++++++++ scripts/test_access_token.sh | 5 +++++ 2 files changed, 14 insertions(+) create mode 100755 scripts/get_refresh_token.sh create mode 100755 scripts/test_access_token.sh diff --git a/scripts/get_refresh_token.sh b/scripts/get_refresh_token.sh new file mode 100755 index 0000000..406b63b --- /dev/null +++ b/scripts/get_refresh_token.sh @@ -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 " \ + -d "code=" \ + -d "redirect_uri=https://localhost:4443/callback" \ + -d "scope=admin" \ + -d "grant_type=authorization_code" diff --git a/scripts/test_access_token.sh b/scripts/test_access_token.sh new file mode 100755 index 0000000..4229530 --- /dev/null +++ b/scripts/test_access_token.sh @@ -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 " \ \ No newline at end of file From b5b734ea9d7ed79d793b2d707152159d75fa5225 Mon Sep 17 00:00:00 2001 From: Leland Krych Date: Mon, 2 Mar 2020 21:38:12 -0800 Subject: [PATCH 5/5] add a little readme --- README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/README.md b/README.md index 650a78c..9efae33 100644 --- a/README.md +++ b/README.md @@ -3,3 +3,17 @@ Test OAuth2 Authorization Code Grant process 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. \ No newline at end of file