Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.
Free Trial

Alteryx Server Discussions

Find answers, ask questions, and share expertise about Alteryx Server.
SOLVED

Passing in Run As Credentials for Job with API

elsastark
10 - Fireball

Hello Community!

 

We are looking at switching our Gallery Workflow Credentials settings to be Require User Credentials - something we have as a requirement is to kick off workflows with the APIs (currently use /user/v2/workflows/{appId}/jobs).

 

When a user uses an API for a job, is there a way to pass in the credentials as this Gallery setting will prompt a user for a credential to use. 

 

Note: We are trying to do this setting instead of Allow User to Select because we have not found a way to publish workflows with the APIs where we can specify the option. I have posted that forum here

7 REPLIES 7
AndrewSu
Alteryx Alumni (Retired)

Hey @elsastark ,

 

At this time, the API cannot accept a raw username/password like the front-end of the Gallery UI (security reasons). The endpoints can be called with a specific credential ID ("credentialId" parameter in the API call) if a Gallery Credential (setup in the Admin section) is configured and the user owning the API key has access to said credential.  see screenshots below. 
 
1. Creating a credential. 
AndrewSu_1-1655524454076.png

 

2. Sharing a Credential.  Must go to "Credential" section and select an existing Credential. Then the screen below appears. 

 

AndrewSu_3-1655524733299.png

 

Otherwise, it will run as the default run-as account (if configured) or service user even if the workflow is set to require user credentials.

 
I hope this provides some clarity!
 
If this helps solve your issue, please mark this as the solution so that other members of the community can easily find the post.  
 
Thanks!
elsastark
10 - Fireball

Hi @AndrewSu - Can you clarify if this works when the Gallery setting is Require User Credentials versus Use Default Credentials?

AndrewSu
Alteryx Alumni (Retired)

@elsastark , the Gallery setting Require User Credentials is only for workflows run from the Gallery.  It is not applied via any API calls except for using the Credential ID that I outlined in my previous post due to security reasons. 

 

If you want users to select their own Credentials to run the API calls, you could map the Credential IDs to the appropriate user and have some sort of interface that allows users to select their own Credentials before running the API call to run the job. 

Bargeton
7 - Meteor

Hello,

 

I try to use the API to run a workflow.

The worklow must be run with another user.

 

When published it from the Desginer, we specifiy the user/password to use.

 

When manually run from the Gallery, it use the "run as" user specified when published.

 

Now from the v1 API

post /v1/workflows/{appId}/jobs

It run the workfow with a "local user", so not the one I want.

 

From the v2 API

post /user/v2/workflows/{appId}/jobs

 

It response:

{ "message": "The credentials could not be found." }

 

So I've tried what described, to go on Admin > Credentials and add the credential I want to use at the "run as".

But then, how in the API give a paramter to use this credential?

 

I've also add me to access to this credential.

But I can have several credentials shared to me, so I need to know how to say to the API to use a specific credential.

 

Regards,

 

Alex

AndrewSu
Alteryx Alumni (Retired)

@Bargeton ,  you can pass the Credential that you want to use within the API request itself.  See the image below. 

 

AndrewSu_0-1679349024463.png

 

You can find the Credential ID by going thru the following steps. 

 

1. Navigate to Server Admin panel

2. Navigate to "Credentials"

3. Select the credential in question. 

4. Locate the ID of the credential from the URL.  It is the last parameter of the URL.  see image below. 

AndrewSu_1-1679349198290.png

 

If this helps resolve your issue, please mark this reply as the solution so that others in the Community can benefit from our collaboration. 

 

Thanks. 

 

 

 

 

Bargeton
7 - Meteor

It's working fine for me now.

Thanks a lot.

AndrewSu
Alteryx Alumni (Retired)

@elsastark ,  is this issue resolved based on the corresponding threads?  if so, please mark the appropriate reply as the solution so that others in the Community can benefit from our collaboration. 

 

Thanks!