Why Can't I Connect My ServiceTitan Account to My Pipedream Service Despite Correct Credentials?

This topic was automatically generated from Slack. You can find the original thread here.

Hello, I am currently facing some issues with connecting my ServiceTitan account to my Pipedream service. I have double checked that I have entered the right credentials, and I am also able to use that same credentials to make API calls and such. So I believe the issue may not be with the login details but something to do with the connection here? Any assistance with this would be greatly appreciated.

can you assist here?

I’m sorry you’re having trouble connecting your ServiceTitan account to Pipedream. Since you’ve already confirmed your credentials work for direct API calls, the issue may be related to how the connection is set up within Pipedream. Here are some troubleshooting steps and key points based on the Pipedream documentation: — ## 1. ServiceTitan OAuth Connection in Pipedream Pipedream uses OAuth to connect to ServiceTitan. When you connect your account, Pipedream expects the following fields: - Client ID - Client Secret - Tenant ID - Environment (e.g., .staging. or . for production) These are used to generate an OAuth access token for API requests. — ## 2. Example of a ServiceTitan API Request in Pipedream Here’s how Pipedream expects to use your credentials in a component: import { axios } from "@pipedream/platform" export default defineComponent({ props: { servicetitan: { type: "app", app: "servicetitan", } }, async run({steps, $}) { return await axios($, { url: `https://api${this.servicetitan.$auth.environment}[servicetitan.io/settings/v2/tenant/${this.servicetitan.$auth.tenant_id}/employees](http://servicetitan.io/settings/v2/tenant/${this.servicetitan.$auth.tenant_id}/employees)`, headers: { Authorization: `Bearer ${this.servicetitan.$auth.oauth_access_token}`, "st-app-key": `${this.servicetitan.$auth.client_id}`, }, }) }, }) — ## 3. Common Issues to Check - OAuth Flow: Make sure you completed the OAuth flow in Pipedream’s UI (not just entering credentials manually). - Correct Environment: The environment field should be set correctly: - For production: leave blank or use . - For staging: use .staging. - Tenant ID: Double-check your tenant ID is correct. - App Key: The st-app-key header must match your client ID. - Token Expiry: If your OAuth token expired, try reconnecting your ServiceTitan account in Pipedream. — ## 4. Next Steps - Try disconnecting and reconnecting your ServiceTitan account in Pipedream. - If you see a specific error message, please share it here for more targeted help. - If the issue persists, please visit Support - Pipedream for more support options. — If you can provide any error messages or screenshots, I can help you further troubleshoot!

Hey I hope all is well? Pi wasn’t too helpful here. Can you check what the issue here with this OAuth2.0 process? We can’t get to a point that we have an Account saved. We enter the correct details. Cheers!

Hey , @U09FQ5LFA75, here’s what I got from our internal error log:

Exception:401 "Access Denied"
Received 401 from the test request:https://api.servicetitan.io/settings/v2/tenant/123456/employees
Decoded error:{"type":"https://tools.ietf.org/html/rfc7231#section-6.5","status":401,"title":"Application key validation failed, check ST-App-Key header value.","traceId":"7b0ece5d-3b52-436b-8652-744451872b31"}

I’m trying to setup a test account on my side to test for end-to-end flow. Though please take a look at the error message to see if it makes sense to you

on another note, could you share your API calls (please remove your credentials) if possible?

Yes of course , give me one moment

here is one sample which returns an access token:

curl -v -X POST "https://auth.servicetitan.io/connect/token" \
  -H "Content-Type: application/x-www-form-urlencoded" \
  --data "grant_type=client_credentials&client_id=<id>&client_secret=<secret>"

In the error message, the tenant id there is wrong I believe, as its not 123456. Its something else and I did attempt to use the right one before that but I got the same error message in the pop up. I can try access it again with the right tenant id.

Yup, just tried again with the right tenantid and i got the same error

Yep I got a different error now. Let me investigate this.

Will get back to you asap

, I’ve just updated the config, could you try again one more time?

Sorry this is a little bit trial and error, since I don’t have a ServiceTitan developer account to test

I’ve just updated again to add a new App Key field. Would you mind:

  1. Refresh your Pipedream page
  2. Try to connect a new ServiceTitan account, you should see the new App Key prop
  3. Copy the App Key (when you create the app) and paste it there

No problem, I will try it and update . Give me a second

Ok perfect, it looks to be connected. I will continue some development with the connection then and see if it works. Thank you so much !!

this was impressive, well done and thanks!

Glad to know! Please let me know any other issue you may have