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

Fix API Key verification endpoint for SlideSpeak API #13754

Open
5 tasks done
pulgamecanica opened this issue Feb 14, 2025 · 1 comment · May be fixed by #13756
Open
5 tasks done

Fix API Key verification endpoint for SlideSpeak API #13754

pulgamecanica opened this issue Feb 14, 2025 · 1 comment · May be fixed by #13756
Labels
🐞 bug Something isn't working cloud When the version is cloud and it is a bug report

Comments

@pulgamecanica
Copy link

Self Checks

  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

0.15.3

Cloud or Self Hosted

Cloud

Steps to reproduce

This PR addresses an issue where the application is not calling the correct endpoint to verify the API key.

Image

✔️ Expected Behavior

It should call the correct API endpoint to correctly check the API Key vailidity.

❌ Actual Behavior

It's calling an endpoint which is not defined, thus never being able to verify the API Key.

Copy link

dosubot bot commented Feb 14, 2025

Hello, @pulgamecanica! I'm here to help you with any bugs, questions, or contributions you have. Let's tackle this API key verification issue together!

To fix the API Key verification endpoint for the SlideSpeak API, ensure that the endpoint URL is correctly constructed and that the API Key is included in the request headers. The endpoint URL should be constructed using the base_url and a test task ID, with the API Key included in the headers as "X-API-Key". Here's a relevant code snippet:

def _validate_credentials(self, credentials: dict[str, Any]) -> None:
    api_key = credentials.get("slidespeak_api_key")
    base_url = credentials.get("base_url")

    if not api_key:
        raise ToolProviderCredentialValidationError("API key is missing")

    if base_url:
        base_url = str(URL(base_url) / "v1")

    headers = {"Content-Type": "application/json", "X-API-Key": api_key}

    test_task_id = "xxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
    url = f"{base_url or 'https://api.slidespeak.co/api/v1'}/task_status/{test_task_id}"

    response = requests.get(url, headers=headers)
    if response.status_code != 200:
        raise ToolProviderCredentialValidationError("Invalid SlidePeak API key")

Ensure that the base_url is correctly set to the SlideSpeak API's base URL, and the API Key is valid and correctly passed in the headers. Additionally, consider using asynchronous requests with aiohttp for better performance, as demonstrated in the SlidesGeneratorTool class [1][2].

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

@dosubot dosubot bot added cloud When the version is cloud and it is a bug report 🐞 bug Something isn't working labels Feb 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working cloud When the version is cloud and it is a bug report
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant