#[Solved ✅] Invalid URL

1 messages · Page 1 of 1 (latest)

blazing belfry
#

I keep getting this error with my oauth flows? What is going wrong here?

{"name":"Internal Server Error","message":""Invalid URL"","stack":"TypeError: Invalid URL\n at new URL (node:internal/url:806:29)\n at AppAuthConnectionController.handleOAuth2Callback (/hermes/apps/hermes/output/webpack:/hermes/src/resources/auth-apps/controller.ts:268:21)"}

wicked kindle
#

It seems to be working fine for me, please re-try using a valid redirect URI

blazing belfry
#

What redirect uris are valid? I was passing my own /auth/oauth/callback. Is this meant to be configured in the app UI?

#

@wicked kindle

rancid nymphBOT
#

Could u please share the code that you're using

carmine badger
#

@blazing belfry

blazing belfry
#
  async getOAuthUrl(data: { pluginId: PluginId; redirectUri?: string }): Promise<string> {
    logger.info('getting oauth url for plugin:' + data.pluginId, { type: 'trace' });
    const plugin = await this.#ctx.pluginProvider.getPlugin(data.pluginId);
    if (!plugin) {
      logger.error('plugin not found', { type: 'trace', data: { pluginId: data.pluginId } });
      throw new Error(`Plugin ${data.pluginId} not found`);
    }
    if (plugin.author !== 'composio') {
      return super.getOAuthUrl(data);
    }
    logger.info('initiating oauth for plugin:' + data.pluginId, { type: 'trace' });
    const entityId = plugin.scope === 'user' ? this.#ctx.auth.userId : this.#ctx.auth.accountId;
    const toolset = new ComposioToolSet({
      apiKey: config.plugins.composio.apiKey,
      entityId,
    });
    const integrationId = (plugin.metadata || {}).composioIntegrationId;
    if (!integrationId) {
      logger.error('plugin has no Composio integration ID', { type: 'trace', data: { pluginId: data.pluginId } });
      throw new Error(`Plugin ${data.pluginId} has no Composio integration ID`);
    }

    const oauthUrl = await toolset.connectedAccounts.initiate({
      integrationId,
      redirectUri: data.redirectUri,
      entityId,
      authConfig: {},
    });
    return oauthUrl.redirectUrl as string;
  }
rancid nymphBOT
#

It seems to be working fine on my end. Please check if you're using the latest SDK & the redirectUri is correct.
So redirectUri is where the user would be redirected post the OAuth flow.

blazing belfry
#

@wicked kindle is this redirectUri meant to be a specific value or can i configure it to be the existing redirectUri for my other integrations.

rancid nymphBOT
#

It need not be any specific value.

carmine badger
#

@blazing belfry

blazing belfry
#

@carmine badger @wicked kindle I keep getting this: {"name":"Internal Server Error","message":""Invalid URL"","stack":"TypeError: Invalid URL\n at new URL (node:internal/url:806:29)\n at AppAuthConnectionController.handleOAuth2Callback (/hermes/apps/hermes/output/webpack:/hermes/src/resources/auth-apps/controller.ts:270:21)"}

#
Failed to load resource: the server responded with a status of 500 ()
wicked kindle