diff --git a/frontend/src/components/Oauth2Auth.jsx b/frontend/src/components/Oauth2Auth.jsx
index 0c680713..34ab2bfc 100644
--- a/frontend/src/components/Oauth2Auth.jsx
+++ b/frontend/src/components/Oauth2Auth.jsx
@@ -13,9 +13,10 @@ const AuthenticationOauth2 = (props) => {
const [defaultConfigSet, setDefaultConfigSet] = React.useState(authenticationType.client_id !== undefined && authenticationType.client_id !== null && authenticationType.client_id.length > 0 && authenticationType.client_secret !== undefined && authenticationType.client_secret !== null && authenticationType.client_secret.length > 0)
const [clientId, setClientId] = React.useState(defaultConfigSet ? authenticationType.client_id : "")
const [clientSecret, setClientSecret] = React.useState(defaultConfigSet ? authenticationType.client_secret : "")
+ const [oauthUrl, setOauthUrl] = React.useState("")
const [buttonClicked, setButtonClicked] = React.useState(false)
- const [manuallyConfigure, setManuallyConfigure] = React.useState(false)
+ const [manuallyConfigure, setManuallyConfigure] = React.useState(defaultConfigSet ? false : true)
const [authenticationOption, setAuthenticationOptions] = React.useState({
app: JSON.parse(JSON.stringify(selectedApp)),
fields: {},
@@ -31,7 +32,7 @@ const AuthenticationOauth2 = (props) => {
return null
}
- const handleOauth2Request = (client_id, client_secret) => {
+ const handleOauth2Request = (client_id, client_secret, oauth_url) => {
setButtonClicked(true)
//if (authenticationType.type === "oauth2" && authenticationType.redirect_uri !== undefined && authenticationType.redirect_uri !== null) {
// These are test credentials
@@ -40,17 +41,26 @@ const AuthenticationOauth2 = (props) => {
const authentication_url = authenticationType.token_uri
- const resources = "UserAuthenticationMethod.ReadWrite.All"
+ var resources = ""
+ console.log("SCOPES: ", resources)
if (authenticationType.scope !== undefined && authenticationType.scope !== null) {
- console.log("EDIT SCOPE!")
+ resources = authenticationType.scope.join(",")
}
- console.log(window.location)
- //const isCloud = window.location.host === "localhost:3002" || window.location.host === "shuffler.io"
- const redirectUri = `${window.location.protocol}//${window.location.host}/set_authentication`
- const state = `workflow_id%3D${workflow.id}%26reference_action_id%3d${selectedAction.app_id}%26app_name%3d${selectedAction.app_name}%26app_id%3d${selectedAction.app_id}%26app_version%3d${selectedAction.app_version}%26authentication_url%3d${authentication_url}%26scope%3d${resources}%26client_id%3d${client_id}%26client_secret%3d${client_secret}`
+ resources = ["AaaServer.profile.READ"]
- const url = `${authenticationType.redirect_uri}?client_id=${client_id}&redirect_uri=${redirectUri}&response_type=code&scope=${resources}&state=${state}`
+ console.log("SCOPES2: ", resources)
+ const redirectUri = `${window.location.protocol}//${window.location.host}/set_authentication`
+ var state = `workflow_id%3D${workflow.id}%26reference_action_id%3d${selectedAction.app_id}%26app_name%3d${selectedAction.app_name}%26app_id%3d${selectedAction.app_id}%26app_version%3d${selectedAction.app_version}%26authentication_url%3d${authentication_url}%26scope%3d${resources}%26client_id%3d${client_id}%26client_secret%3d${client_secret}`
+ if (oauth_url !== undefined && oauth_url !== null && oauth_url.length > 0) {
+ state += `%26oauth_url%3d${oauth_url}`
+ console.log("ADDING OAUTH2 URL: ", state)
+ }
+ const url = `${authenticationType.redirect_uri}?client_id=${client_id}&redirect_uri=${redirectUri}&response_type=code&scope=${resources}&prompt=consent&state=${state}`
+
+ //const url = `https://accounts.zoho.com/oauth/v2/auth?response_type=code&client_id=${client_id}&scope=AaaServer.profile.Read&redirect_uri=${redirectUri}&prompt=consent`
+ console.log("Full URI: ", url)
+ console.log("Redirect Uri: ", redirectUri)
// &resource=https%3A%2F%2Fgraph.microsoft.com&
// FIXME: Awful, but works for prototyping
@@ -64,14 +74,11 @@ const AuthenticationOauth2 = (props) => {
var open = true
const timer = setInterval(() => {
if (newwin.closed) {
+ setButtonClicked(false)
clearInterval(timer);
//alert('"Secure Payment" window closed!');
getAppAuthentication(true, true)
- setTimeout(() => {
- console.log("APPAUTH: ", appAuthentication)
- setAuthenticationModalOpen(false)
- }, 1500)
}
}, 1000);
//do {
@@ -206,6 +213,75 @@ const AuthenticationOauth2 = (props) => {
{!manuallyConfigure ? null :
+ {selectedApp.authentication.parameters.map((data, index) => {
+ //console.log(data, index)
+ if (data.name === "client_id" || data.name === "client_secret") {
+ return null
+ }
+
+ if (data.name !== "url") {
+ return null
+ }
+
+ if (oauthUrl.length === 0) {
+ setOauthUrl(data.value)
+ }
+
+ return (
+
+
+ {data.name}
+
+ {data.schema !== undefined && data.schema !== null && data.schema.type === "bool" ?
+
+ :
+ {
+ authenticationOption.fields[data.name] = event.target.value
+ console.log("Setting oauth url")
+ setOauthUrl(event.target.value)
+ //const [oauthUrl, setOauthUrl] = React.useState("")
+ }}
+ />
+ }
+
+ )
+ })}
{
}
- : null}
+ :
+ null
+ }
)
diff --git a/frontend/src/views/AngularWorkflow.jsx b/frontend/src/views/AngularWorkflow.jsx
index 8c4558db..b6029cd5 100644
--- a/frontend/src/views/AngularWorkflow.jsx
+++ b/frontend/src/views/AngularWorkflow.jsx
@@ -1227,6 +1227,7 @@ const AngularWorkflow = (props) => {
if (selectedApp.authentication.required) {
//console.log("App requires auth!!")
// Setup auth here :)
+ var appUpdates = false
const authenticationOptions = []
var findAuthId = ""
if (selectedAction.authentication_id !== null && selectedAction.authentication_id !== undefined && selectedAction.authentication_id.length > 0) {
@@ -1261,6 +1262,7 @@ const AngularWorkflow = (props) => {
console.log("Setting auth at: ", workflow.actions[key], item.id)
workflow.actions[key].selectedAuthentication = item
workflow.actions[key].authentication_id = item.id
+ appUpdates = true
//if (workflow.actions[key].selectedAuthentication === undefined || workflow.actions[key].selectedAuthentication === null || workflow.actions[key].selectedAuthentication.length === 0) {
// console.log("Setting inner auth: ", workflow.actions[key])
//}
@@ -1282,12 +1284,16 @@ const AngularWorkflow = (props) => {
selectedAction.selectedAuthentication = {}
}
- setSelectedAction(selectedAction)
- setWorkflow(workflow)
- saveWorkflow(workflow)
- //for (var key in
- alert.info("Added and updated authentication!")
+ if (appUpdates === true) {
+ setAuthenticationModalOpen(false)
+ setSelectedAction(selectedAction)
+ setWorkflow(workflow)
+ saveWorkflow(workflow)
+ alert.info("Added and updated authentication!")
+ } else {
+ alert.error("Failed to find new authentication - did it work?")
+ }
} else {
alert.info("No authentication to update")
}
@@ -2098,6 +2104,7 @@ const AngularWorkflow = (props) => {
{
"type": "oauth2",
"redirect_uri": curapp.authentication.redirect_uri,
+ "refresh_uri": curapp.authentication.refresh_uri,
"token_uri": curapp.authentication.token_uri,
"scope": curapp.authentication.scope,
"client_id": curapp.authentication.client_id,
@@ -2946,7 +2953,7 @@ const AngularWorkflow = (props) => {
//console.log(event.keyCode)
switch( event.keyCode ) {
case 27:
- console.log("ESCAPE")
+ //console.log("ESCAPE")
if (configureWorkflowModalOpen === true) {
setConfigureWorkflowModalOpen(false)
}
@@ -9271,7 +9278,7 @@ const AngularWorkflow = (props) => {
// This whole part is redundant. Made it part of Arguments instead.
- console.log(selectedApp)
+ //console.log(selectedApp)
const authenticationModal = authenticationModalOpen ?