Making "credential_request" type Parameter Optional in Plugin

Suhail
Suhail Registered Posts: 18 ✭✭✭✭

Hello Everyone,

I'm reaching out today with a question regarding a plugin I've been working on. I followed the parameter guidelines, and everything seems to be in order except for one issue. I'm struggling to make the "credential_request" type parameter optional, and I could really use your expertise and guidance to solve this problem.

The challenge I'm facing is that whenever I run the plugin without explicitly setting the "credential_request" parameter, an error pops up saying, "User does not have credentials for plugin credentials request." I want to modify the plugin in such a way that the "credential_request" parameter becomes optional, allowing users to run the plugin without providing credentials as the plugin performs 2 operations, one of which does not need the credential_request parameter at all.

I've reviewed the guidelines thoroughly, but I'm unable to identify the specific changes required to make the "credential_request" parameter optional. I've tried a few approaches, but none have worked so far. That's why I'm turning to you, our talented community, for assistance.

Could you kindly share your insights and suggestions on how to tackle this problem? If any of you have experience working with similar issues or have ideas on how to make the "credential_request" parameter optional, I would greatly appreciate your input. Feel free to share code snippets, resources, or any other relevant information that could help me find a solution.


Operating system used: MacOs

Answers

  • AlexB
    AlexB Dataiker, Registered Posts: 68 Dataiker

    Hi

    What you could do is to have a first selector in your json file, where you choose the type of credential the plugin is component is going to use. Then, use a visibilityCondition to hide/show the preset containing the credential request.

    You can find an example of this in the SharePoint Online plugin for instance. In the connector.json there is a auth_type selector. The visibility of sharepoint_oauth, the only preset that contains a credential request, is linked to it.

    In you case, since the credentials are only used for some operations of the plugin, you might also want to split the functionalities into several components for instance, or have use a select for the type of operation to perform, and make the visibility of the credential preset depending on the operation selected.

  • Suhail
    Suhail Registered Posts: 18 ✭✭✭✭

    Hi @AlexB

    Thank you for your response.

    I did follow the SharePoint plugin example. However, despite the visibility condition functioning correctly and the credential_request type parameter being hidden, I am still encountering the same error that was previously experienced.

    For your convenience and reference, I have attached screenshots depicting the parameter set configuration, recipe parameter configuration, and the corresponding error statement.

  • AlexB
    AlexB Dataiker, Registered Posts: 68 Dataiker

    This all seem correct to me... I cannot see the SELECT though, just make sure to use the value in your visibilityCondition, not the label. Also make sure that "creds" is the name of the directory containing your parameter-set.json file.

    Another possible explanation, given that you are in development stage of your plugin, is that the project you are using for testing is polluted by previous versions of you plugin's data structure. The fix for that is to:

    - press Application > Plugins > Development > Your plugin > Actions > Reload this plugin

    - do a hard refresh of you browser (shift + command + R on mac / ctrl + F5 on PC)

    - create a new instance of you plugin in your test project.

    ... every time there is any change to one of the .json files.

  • Suhail
    Suhail Registered Posts: 18 ✭✭✭✭

    Hi @AlexB
    ,

    yes creds is the directory name for my parameter set json file and i did try all the steps you mentioned but still stuck with same error.

    Only way i can think of currently is to create separate components for each operation and not add creds as a parameter in one of the component.

    i wanted to check if there is a better way than just creating new components for each operation.

Setup Info
    Tags
      Help me…