Skip to content

Fix 403 by migrating DeepL auth from legacy body auth to header auth#59

Open
dokokanokafka wants to merge 1 commit intoslack-samples:mainfrom
dokokanokafka:fix/deepl-request
Open

Fix 403 by migrating DeepL auth from legacy body auth to header auth#59
dokokanokafka wants to merge 1 commit intoslack-samples:mainfrom
dokokanokafka:fix/deepl-request

Conversation

@dokokanokafka
Copy link

@dokokanokafka dokokanokafka commented Mar 2, 2026

背景 / Background

  • 翻訳処理で 403 が発生していた。 / Translation workflow was failing with 403.

原因 / Cause

  • 以前の実装は、DeepL に auth_keyrequest body で送る方式だった。 / The previous implementation sent DeepL auth_key in the request body.
  • 現在の DeepL は、Authorization: DeepL-Auth-Key <key>header 認証方式 が前提。 / Current DeepL authentication expects header-based auth via Authorization: DeepL-Auth-Key <key>.
  • 旧方式のままだと 403 になる。 / Keeping the legacy method results in 403.

改善内容 / Improvements

  • 認証方式を旧方式から新方式へ更新。 / Migrated auth from legacy body-based method to header-based method.
  • auth_key の body 送信を廃止し、Authorization ヘッダへ移行。 / Removed body auth_key and moved authentication to Authorization header.
  • DEEPL_AUTH_KEY の前後空白・引用符を除去してから使用するよう改善。 / Added normalization for DEEPL_AUTH_KEY (trim + quote stripping).
  • Free/Pro のエンドポイント判定を安定化(:fx 判定)。 / Stabilized Free/Pro endpoint selection (:fx detection).
  • 403時に DeepL の response body も出力して、次回の確認をしやすくした。 / Included DeepL response body in 403 errors for clearer follow-up.

テスト / Testing

  • deno fmt functions/translate.ts functions/translate_test.ts
  • deno test functions/translate_test.ts
  • ok | 5 passed | 0 failed

@dokokanokafka dokokanokafka requested a review from a team as a code owner March 2, 2026 12:04
@salesforce-cla
Copy link

salesforce-cla bot commented Mar 2, 2026

Thanks for the contribution! Unfortunately we can't verify the commit author(s): Kido Haruhi <k***@e***.com>. One possible solution is to add that email to your GitHub account. Alternatively you can change your commits to another email and force push the change. After getting your commits associated with your GitHub account, sign the Salesforce Inc. Contributor License Agreement and this Pull Request will be revalidated.

@dokokanokafka dokokanokafka changed the title fix:deepl request Fix 403 by migrating DeepL auth from legacy body auth to header auth Mar 2, 2026
@dokokanokafka
Copy link
Author

@seratch

以前本リポジトリで相談させていただいたものです。
今月から有効なAPIキーなはずなものの、403エラーとなる事象を見受けたので
修正のPRを出させていただきました。
salesforce-claは一旦無視しておりますが
ご確認よろしくお願いします。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant