Snowflake OAuth2 integration failure - snowflake_sql plugin #837

Closed
opened 2026-02-16 10:20:40 -05:00 by yindo · 3 comments
Owner

Originally created by @HABE-WAKAM on GitHub (Nov 26, 2025).

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 Dify issues & Dify Official Plugins, 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

1.9.1

Plugin version

0.0.1

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

Add snowflake_sql integration into dify
Create the OAuth integration on Snowflake following the documentation
Install the plugin
Follow the plugin documentation to configure the connection using the right uri. We used the indicated callback uri in the plugin integration : /console/api/oauth/plugin/langgenius/snowflake_sql/snowflake_sql/tool/callback

✔️ Error log

Image
Originally created by @HABE-WAKAM on GitHub (Nov 26, 2025). ### Self Checks - [x] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [x] I have searched for existing issues [Dify issues](https://github.com/langgenius/dify/issues) & [Dify Official Plugins](https://github.com/langgenius/dify-official-plugins/issues), including closed ones. - [x] I confirm that I am using English to submit this report (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [x] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:) - [x] Please do not modify this template :) and fill in all the required fields. ### Dify version 1.9.1 ### Plugin version 0.0.1 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce Add snowflake_sql integration into dify Create the OAuth integration on Snowflake following [the documentation ](https://github.com/langgenius/dify-official-plugins/tree/main/tools/snowflake#1-create-oauth-integration-in-snowflake) Install the plugin Follow the plugin documentation to configure the connection using the right uri. We used the indicated callback uri in the plugin integration : /console/api/oauth/plugin/langgenius/snowflake_sql/snowflake_sql/tool/callback ### ✔️ Error log <img width="599" height="601" alt="Image" src="https://github.com/user-attachments/assets/0be7391a-72b1-4909-9922-a0cda2e675f4" />
yindo added the bug label 2026-02-16 10:20:40 -05:00
yindo closed this issue 2026-02-16 10:20:40 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Nov 26, 2025):

Hi @HABE-WAKAM! I'm Dosu and I’m helping the dify-official-plugins team.

The redirect URI mismatch error happens when the URI used in the OAuth flow does not exactly match what you registered in your Snowflake OAuth integration. Dify constructs the redirect URI dynamically using your configured base URL (protocol, domain, port) plus the path /console/api/oauth/plugin/langgenius/snowflake_sql/snowflake_sql/tool/callback — this must be an exact match, including protocol (http vs https), domain, port, and any trailing slashes, with what you registered in Snowflake’s OAuth client settings. Even a small difference (like a missing port or using localhost vs a public domain) will cause this error.

To resolve this:

  1. In your Dify instance, determine the full redirect URI being used. It will be:
    {your Dify CONSOLE_API_URL}/console/api/oauth/plugin/langgenius/snowflake_sql/snowflake_sql/tool/callback
    
    For example, if you access Dify at https://mydify.example.com, the redirect URI should be:
    https://mydify.example.com/console/api/oauth/plugin/langgenius/snowflake_sql/snowflake_sql/tool/callback
    
  2. In your Snowflake OAuth integration, ensure the registered redirect URI is exactly the same as above.
  3. If you use a reverse proxy, custom domain, or non-standard port, make sure the URI matches what is externally accessible.
  4. Double-check for typos, missing ports, protocol mismatches, or trailing slash differences.

The plugin and backend do not modify or normalize the redirect URI, so it must be an exact string match between Dify and Snowflake for OAuth to succeed. You can see how Dify constructs this URI in the backend code and plugin logic — it always uses the base URL plus the callback path, and passes this directly to Snowflake during the OAuth flow (reference, reference).

If you update the registered redirect URI in Snowflake to match exactly what Dify is using, the OAuth2 integration should work.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

Open in Cursor Join Discord Share on X

@dosubot[bot] commented on GitHub (Nov 26, 2025): <!-- Greeting --> Hi @HABE-WAKAM! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the dify-official-plugins team. <!-- Answer --> The redirect URI mismatch error happens when the URI used in the OAuth flow does not exactly match what you registered in your Snowflake OAuth integration. Dify constructs the redirect URI dynamically using your configured base URL (protocol, domain, port) plus the path `/console/api/oauth/plugin/langgenius/snowflake_sql/snowflake_sql/tool/callback` — this must be an exact match, including protocol (`http` vs `https`), domain, port, and any trailing slashes, with what you registered in Snowflake’s OAuth client settings. Even a small difference (like a missing port or using `localhost` vs a public domain) will cause this error. To resolve this: 1. In your Dify instance, determine the full redirect URI being used. It will be: ``` {your Dify CONSOLE_API_URL}/console/api/oauth/plugin/langgenius/snowflake_sql/snowflake_sql/tool/callback ``` For example, if you access Dify at `https://mydify.example.com`, the redirect URI should be: ``` https://mydify.example.com/console/api/oauth/plugin/langgenius/snowflake_sql/snowflake_sql/tool/callback ``` 2. In your Snowflake OAuth integration, ensure the registered redirect URI is exactly the same as above. 3. If you use a reverse proxy, custom domain, or non-standard port, make sure the URI matches what is externally accessible. 4. Double-check for typos, missing ports, protocol mismatches, or trailing slash differences. The plugin and backend do not modify or normalize the redirect URI, so it must be an exact string match between Dify and Snowflake for OAuth to succeed. You can see how Dify constructs this URI in the backend code and plugin logic — it always uses the base URL plus the callback path, and passes this directly to Snowflake during the OAuth flow ([reference](https://github.com/langgenius/dify/blob/b2a7cec644e79c5c5e38f983d9466254414a7b5d/api/controllers/console/workspace/tool_providers.py#L717-L807), [reference](https://github.com/langgenius/dify-official-plugins/blob/1dd51cd351698fff818facea860a359293bfbe90/tools/snowflake/provider/snowflake_sql.py#L20-L102)). If you update the registered redirect URI in Snowflake to match exactly what Dify is using, the OAuth2 integration should work. <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/fcb535a1-2a1f-469d-ba93-3710a267f8d6?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/fcb535a1-2a1f-469d-ba93-3710a267f8d6?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/fcb535a1-2a1f-469d-ba93-3710a267f8d6?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/fcb535a1-2a1f-469d-ba93-3710a267f8d6?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/fcb535a1-2a1f-469d-ba93-3710a267f8d6?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/fcb535a1-2a1f-469d-ba93-3710a267f8d6?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/fcb535a1-2a1f-469d-ba93-3710a267f8d6?feedback_type=other)</sup> [![Open in Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=The%20redirect%20URI%20mismatch%20error%20happens%20when%20the%20URI%20used%20in%20the%20OAuth%20flow%20does%20not%20exactly%20match%20what%20you%20registered%20in%20your%20Snowflake%20OAuth%20integration.%20Dify%20constructs%20the%20redirect%20URI%20dynamically%20using%20your%20configured%20base%20URL%20%28protocol%2C%20domain%2C%20port%29%20plus%20the%20path%20%60/console/api/oauth/plugin/langgenius/snowflake_sql/snowflake_sql/tool/callback%60%C2%A0%E2%80%94%C2%A0this%20must%20be%20an%20exact%20match%2C%20including%20protocol%20%28%60http%60%20vs%20%60https%60%29%2C%20domain%2C%20port%2C%20and%20any%20trailing%20slashes%2C%20with%20what%20you%20registered%20in%20Snowflake%E2%80%99s%20OAuth%20client%20settings.%20Even%20a%20small%20difference%20%28like%20a%20missing%20port%20or%20using%20%60localhost%60%20vs%20a%20public%20domain%29%20will%20cause%20this%20error.%20%0A%0ATo%20resolve%20this%3A%0A1.%20In%20your%20Dify%20instance%2C%20determine%20the%20full%20redirect%20URI%20being%20used.%20It%20will%20be%3A%20%20%0A%20%20%20%60%60%60%0A%20%20%20%7Byour%20Dify%20CONSOLE_API_URL%7D/console/api/oauth/plugin/langgenius/snowflake_sql/snowflake_sql/tool/callback%0A%20%20%20%60%60%60%0A%20%20%20For%20example%2C%20if%20you%20access%20Dify%20at%20%60https%3A//mydify.example.com%60%2C%20the%20redirect%20URI%20should%20be%3A%20%20%0A%20%20%20%60%60%60%0A%20%20%20https%3A//mydify.example.com/console/api/oauth/plugin/langgenius/snowflake_sql/snowflake_sql/tool/callback%0A%20%20%20%60%60%60%0A2.%20In%20your%20Snowflake%20OAuth%20integration%2C%20ensure%20the%20registered%20redirect%20URI%20is%20exactly%20the%20same%20as%20above.%0A3.%20If%20you%20use%20a%20reverse%20proxy%2C%20custom%20domain%2C%20or%20non-standard%20port%2C%20make%20sure%20the%20URI%20matches%20what%20is%20externally%20accessible.%0A4.%20Double-check%20for%20typos%2C%20missing%20ports%2C%20protocol%20mismatches%2C%20or%20trailing%20slash%20differences.%0A%0AThe%20plugin%20and%20backend%20do%20not%20modify%20or%20normalize%20the%20redirect%20URI%2C%20so%20it%20must%20be%20an%20exact%20string%20match%20between%20Dify%20and%20Snowflake%20for%20OAuth%20to%20succeed.%20You%20can%20see%20how%20Dify%20constructs%20this%20URI%20in%20the%20backend%20code%20and%20plugin%20logic%C2%A0%E2%80%94%C2%A0it%20always%20uses%20the%20base%20URL%20plus%20the%20callback%20path%2C%20and%20passes%20this%20directly%20to%20Snowflake%20during%20the%20OAuth%20flow%20%28%5Breference%5D%28https%3A//github.com/langgenius/dify/blob/b2a7cec644e79c5c5e38f983d9466254414a7b5d/api/controllers/console/workspace/tool_providers.py%23L717-L807%29%2C%20%5Breference%5D%28https%3A//github.com/langgenius/dify-official-plugins/blob/1dd51cd351698fff818facea860a359293bfbe90/tools/snowflake/provider/snowflake_sql.py%23L20-L102%29%29.%0A%0AIf%20you%20update%20the%20registered%20redirect%20URI%20in%20Snowflake%20to%20match%20exactly%20what%20Dify%20is%20using%2C%20the%20OAuth2%20integration%20should%20work.)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/langgenius/dify-official-plugins/issues/2139)
Author
Owner

@HABE-WAKAM commented on GitHub (Dec 3, 2025):

@dosu
I have checked the URI and its the good one.
When I try to open the callback URI on my browser I have a 403 error.
{"code":"forbidden","message":"context_id not found","status":403}

@HABE-WAKAM commented on GitHub (Dec 3, 2025): @dosu I have checked the URI and its the good one. When I try to open the callback URI on my browser I have a 403 error. {"code":"forbidden","message":"context_id not found","status":403}
Author
Owner

@dosubot[bot] commented on GitHub (Dec 3, 2025):

The 403 error with "context_id not found" happens because the OAuth2 callback endpoint expects a special context (a context_id cookie) that Dify sets when you start the OAuth flow from within the Dify UI. If you open the callback URI directly in your browser, that context is missing, so the endpoint always returns this error.

To complete the OAuth2 flow, you need to initiate the Snowflake integration from Dify itself (not by manually visiting the callback URL). Dify will redirect you to Snowflake for authorization, then Snowflake will redirect you back to the callback URI with all the required context and parameters. This is a security measure to prevent unauthorized access and CSRF attacks.

If you follow the flow from the Dify UI and still get errors, double-check that your redirect URI matches exactly in both Dify and Snowflake, and make sure your browser allows cookies for your Dify domain. If you still have trouble after following the correct flow, let me know what step fails and what error you see.

You can see the relevant logic in the Dify backend here:
OAuth callback expects context_id cookie and validates it
OAuth proxy context creation and validation

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

Open in Cursor Join Discord Share on X

@dosubot[bot] commented on GitHub (Dec 3, 2025): <!-- Answer --> The 403 error with "context_id not found" happens because the OAuth2 callback endpoint expects a special context (a context_id cookie) that Dify sets when you start the OAuth flow from within the Dify UI. If you open the callback URI directly in your browser, that context is missing, so the endpoint always returns this error. To complete the OAuth2 flow, you need to initiate the Snowflake integration from Dify itself (not by manually visiting the callback URL). Dify will redirect you to Snowflake for authorization, then Snowflake will redirect you back to the callback URI with all the required context and parameters. This is a security measure to prevent unauthorized access and CSRF attacks. If you follow the flow from the Dify UI and still get errors, double-check that your redirect URI matches exactly in both Dify and Snowflake, and make sure your browser allows cookies for your Dify domain. If you still have trouble after following the correct flow, let me know what step fails and what error you see. You can see the relevant logic in the Dify backend here: [OAuth callback expects context_id cookie and validates it](https://github.com/langgenius/dify/blob/31481581e8dbf126796802e1e8076b710e4a49f3/api/controllers/console/workspace/tool_providers.py#L717-L807) [OAuth proxy context creation and validation](https://github.com/langgenius/dify/blob/31481581e8dbf126796802e1e8076b710e4a49f3/api/services/plugin/oauth_service.py#L14-L65) <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/d69c18cf-7419-405f-83f0-1dd97daf06a4?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/d69c18cf-7419-405f-83f0-1dd97daf06a4?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/d69c18cf-7419-405f-83f0-1dd97daf06a4?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/d69c18cf-7419-405f-83f0-1dd97daf06a4?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/d69c18cf-7419-405f-83f0-1dd97daf06a4?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/d69c18cf-7419-405f-83f0-1dd97daf06a4?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/d69c18cf-7419-405f-83f0-1dd97daf06a4?feedback_type=other)</sup> [![Open in Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=The%20403%20error%20with%20%22context_id%20not%20found%22%20happens%20because%20the%20OAuth2%20callback%20endpoint%20expects%20a%20special%20context%20%28a%20context_id%20cookie%29%20that%20Dify%20sets%20when%20you%20start%20the%20OAuth%20flow%20from%20within%20the%20Dify%20UI.%20If%20you%20open%20the%20callback%20URI%20directly%20in%20your%20browser%2C%20that%20context%20is%20missing%2C%20so%20the%20endpoint%20always%20returns%20this%20error.%20%0A%0ATo%20complete%20the%20OAuth2%20flow%2C%20you%20need%20to%20initiate%20the%20Snowflake%20integration%20from%20Dify%20itself%20%28not%20by%20manually%20visiting%20the%20callback%20URL%29.%20Dify%20will%20redirect%20you%20to%20Snowflake%20for%20authorization%2C%20then%20Snowflake%20will%20redirect%20you%20back%20to%20the%20callback%20URI%20with%20all%20the%20required%20context%20and%20parameters.%20This%20is%20a%20security%20measure%20to%20prevent%20unauthorized%20access%20and%20CSRF%20attacks.%20%0A%0AIf%20you%20follow%20the%20flow%20from%20the%20Dify%20UI%20and%20still%20get%20errors%2C%20double-check%20that%20your%20redirect%20URI%20matches%20exactly%20in%20both%20Dify%20and%20Snowflake%2C%20and%20make%20sure%20your%20browser%20allows%20cookies%20for%20your%20Dify%20domain.%20If%20you%20still%20have%20trouble%20after%20following%20the%20correct%20flow%2C%20let%20me%20know%20what%20step%20fails%20and%20what%20error%20you%20see.%20%0A%0AYou%20can%20see%20the%20relevant%20logic%20in%20the%20Dify%20backend%20here%3A%20%20%0A%5BOAuth%20callback%20expects%20context_id%20cookie%20and%20validates%20it%5D%28https%3A//github.com/langgenius/dify/blob/31481581e8dbf126796802e1e8076b710e4a49f3/api/controllers/console/workspace/tool_providers.py%23L717-L807%29%20%20%0A%5BOAuth%20proxy%20context%20creation%20and%20validation%5D%28https%3A//github.com/langgenius/dify/blob/31481581e8dbf126796802e1e8076b710e4a49f3/api/services/plugin/oauth_service.py%23L14-L65%29)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/langgenius/dify-official-plugins/issues/2139)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify-official-plugins#837