Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can we prevent connection creation? #163

Open
Ripchanskiy opened this issue May 23, 2023 · 0 comments
Open

Can we prevent connection creation? #163

Ripchanskiy opened this issue May 23, 2023 · 0 comments

Comments

@Ripchanskiy
Copy link

Hello.
We created our custom Google SSO connector.
When user connect to this connector with account that doesn't have google workspace. Connector allows us to connect and we see that connector wiget connected at Workato UI.
But when we trying to start recipe that uses this connector we see error

We can't start this recipe due to connection errors
Google SSO is not connected.

It's confusing customers because it's not clear that we have connection issue.

But if account with Google Workspace it's works as expected.
So, do you know something about this broblem and how to fix it? It looks like workato widget issue

Here is how connector looks like

`
{
title: "TEST Google SSO",

connection: {
fields: [
{
name: "client_id",
optional: false
},
{
name: "client_secret",
optional: false,
control_type: "password"
}
],

authorization: {
  type: "oauth2",

  authorization_url: lambda do |connection|
    scopes = [
      "https://www.googleapis.com/auth/admin.reports.audit.readonly",
      "https://www.googleapis.com/auth/admin.reports.usage.readonly",
      "https://www.googleapis.com/auth/admin.directory.user.readonly"
    ].join(" ")

    "https://accounts.google.com/o/oauth2/auth?client_id=" \
    "#{connection['client_id']}&response_type=code&scope=#{scopes}" \
    "&access_type=offline&include_granted_scopes=true&prompt=consent"
  end,

  acquire: lambda do |connection, auth_code, redirect_uri|
    response = post("https://accounts.google.com/o/oauth2/token").
      payload(client_id: connection["client_id"],
              client_secret: connection["client_secret"],
              grant_type: "authorization_code",
              code: auth_code,
              redirect_uri: redirect_uri).
      request_format_www_form_urlencoded
    [response, nil, nil]
  end,

  refresh: lambda do |connection, refresh_token|
    post("https://accounts.google.com/o/oauth2/token").
      payload(client_id: connection["client_id"],
              client_secret: connection["client_secret"],
              grant_type: "refresh_token",
              refresh_token: refresh_token).
      request_format_www_form_urlencoded
  end,

  refresh_on: [401],

  detect_on: [/"errors"\:\s*\[/],

  apply: lambda do |_connection, access_token|
    headers("Authorization" => "Bearer #{access_token}")
  end
},

base_uri: lambda do |_connection|
  "https://www.googleapis.com"
end

},

object_definitions: {},

custom_action: true,

test: lambda do |_connection|
get("/admin/reports/v1/activity/users/all/applications/token")
end,

triggers: {}
}`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant