diff --git a/lang/en-US.js b/lang/en-US.js
index 317b9718e..280da3e56 100644
--- a/lang/en-US.js
+++ b/lang/en-US.js
@@ -86,5 +86,19 @@ export default {
connect: "Connect",
disconnect: "Disconnect",
start: "Start",
- stop: "Stop"
+ stop: "Stop",
+ access_token: "Access Token",
+ get_token: "Get New Token",
+ manage_token: "Manage Access Token",
+ save_token: "Save Access Token",
+ use_token: "Use Saved Token",
+ request_token: "Request Token",
+ save_token_request: "Save Token Request",
+ token_name: "Token Name",
+ oidc_discovery_url: "OIDC Discovery URL",
+ auth_url: "Auth URL",
+ access_token_url: "Access Token URL",
+ client_id: "Client ID",
+ scope: "Scope",
+ state: "State",
};
diff --git a/package-lock.json b/package-lock.json
index a17a13373..2b47598bf 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,6 +1,6 @@
{
"name": "postwoman",
- "version": "1.0.0",
+ "version": "1.5.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
diff --git a/pages/index.vue b/pages/index.vue
index 0549a247f..63c1015e6 100644
--- a/pages/index.vue
+++ b/pages/index.vue
@@ -388,11 +388,29 @@
@@ -404,6 +422,118 @@
+
+
+ -
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+
+
+
+
@@ -805,6 +935,86 @@
+
+
+
+
+ -
+
+
{{ $t("save_token_request") }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+
+
{{ $t("manage_token") }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -901,6 +1111,9 @@ export default {
previewEnabled: false,
paramsWatchEnabled: true,
expandResponse: false,
+ showTokenList: false,
+ showTokenRequest: false,
+ showTokenRequestList: false,
/**
* These are content types that can be automatically
@@ -1208,6 +1421,70 @@ export default {
this.$store.commit("setState", { value, attribute: "bearerToken" });
}
},
+ token: {
+ get() {
+ return this.$store.oauth2.token;
+ },
+ set(value) {
+ this.$store.commit("setOauth2", { value, attribute: "token" });
+ }
+ },
+ accessTokenName: {
+ get() {
+ return this.$store.state.oauth2.accessTokenName;
+ },
+ set(value) {
+ this.$store.commit("setOauth2", { value, attribute: "accessTokenName" });
+ }
+ },
+ oidcDiscoveryUrl: {
+ get() {
+ return this.$store.state.oauth2.oidcDiscoveryUrl;
+ },
+ set(value) {
+ this.$store.commit("setOauth2", { value, attribute: "oidcDiscoveryUrl" });
+ }
+ },
+ authUrl: {
+ get() {
+ return this.$store.state.oauth2.authUrl;
+ },
+ set(value) {
+ this.$store.commit("setOauth2", { value, attribute: "authUrl" });
+ }
+ },
+ accessTokenUrl: {
+ get() {
+ return this.$store.state.oauth2.accessTokenUrl;
+ },
+ set(value) {
+ this.$store.commit("setOauth2", { value, attribute: "accessTokenUrl" });
+ }
+ },
+ clientId: {
+ get() {
+ return this.$store.state.oauth2.clientId;
+ },
+ set(value) {
+ this.$store.commit("setOauth2", { value, attribute: "clientId" });
+ }
+ },
+ scope: {
+ get() {
+ return this.$store.state.oauth2.scope;
+ },
+ set(value) {
+ this.$store.commit("setOauth2", { value, attribute: "scope" });
+ }
+ },
+ state: {
+ get() {
+ return this.$store.state.oauth2.state;
+ },
+ set(value) {
+ this.$store.commit("setOauth2", { value, attribute: "state" });
+ }
+ },
headers: {
get() {
return this.$store.state.request.headers;
@@ -2045,6 +2322,7 @@ export default {
this.httpUser = "";
this.httpPassword = "";
this.bearerToken = "";
+ this.showTokenRequest = false;
break;
case "headers":
this.headers = [];
@@ -2052,6 +2330,14 @@ export default {
case "parameters":
this.params = [];
break;
+ case "access_token":
+ this.accessTokenName = "";
+ this.oidcDiscoveryUrl = "";
+ this.authUrl = "";
+ this.accessTokenUrl = "";
+ this.clientId = "";
+ this.scope = "";
+ break;
default:
(this.label = ""),
(this.method = "GET"),
@@ -2150,6 +2436,45 @@ export default {
icon: "attach_file"
});
}
+ },
+ async handleAccessTokenRequest(){
+ const tokenReqParams = {
+ grantType: "code",
+ oidcDiscoveryUrl: this.oidcDiscoveryUrl,
+ authUrl: this.authUrl,
+ accessTokenUrl: this.accessTokenUrl,
+ clientId: this.clientId,
+ clientSecret: this.clientSecret,
+ scope: this.scope,
+ clientAuth: this.clientAuth
+ };
+ await tokenRequest(tokenReqParams);
+ },
+ async oauthRedirectReq() {
+ let tokenInfo = await oauthRedirect();
+ if(tokenInfo.hasOwnProperty('access_token')) {
+ this.accessToken = tokenInfo.access_token;
+ }
+ },
+ saveToken(){
+ try {
+ this.$toast.info("Access token saved");
+ this.showTokenList = false;
+ } catch (e) {
+ this.$toast.error(e, {
+ icon: "code"
+ });
+ }
+ },
+ saveTokenRequest(){
+ try {
+ this.$toast.info("Token request saved");
+ this.showTokenRequestList = false;
+ } catch (e) {
+ this.$toast.error(e, {
+ icon: "code"
+ });
+ }
}
},
mounted() {
diff --git a/store/mutations.js b/store/mutations.js
index 61bfd4757..67d17b696 100644
--- a/store/mutations.js
+++ b/store/mutations.js
@@ -85,5 +85,9 @@ export default {
setValueBodyParams({ request }, { index, value }) {
request.bodyParams[index].value = value;
+ },
+
+ setOauth2({ oauth2 }, { attribute, value }) {
+ oauth2[attribute] = value;
}
};
diff --git a/store/state.js b/store/state.js
index 3f8a25da1..4e9e06c54 100644
--- a/store/state.js
+++ b/store/state.js
@@ -22,5 +22,15 @@ export default () => ({
headers: [],
variables: [],
query: ""
+ },
+ oauth2: {
+ token: [],
+ accessTokenName: "",
+ oidcDiscoveryUrl: "",
+ authUrl: "",
+ accessTokenUrl: "",
+ clientId: "",
+ scope: "",
+ state: "",
}
});