error message:authorization config header is required #4478

Closed
opened 2026-02-21 18:06:42 -05:00 by yindo · 3 comments
Owner

Originally created by @DDDU123 on GitHub (Jul 6, 2024).

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).
  • 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

0.6.12-fix1

Cloud or Self Hosted

Cloud

Steps to reproduce

I got this error message when running the HTTP node: "authorization config header is required." But everything was working fine before yesterday, and I haven't made any changes to the authorization.
企业微信截图_20240706163352企业微信截图_20240706163345

✔️ Expected Behavior

No response

Actual Behavior

No response

Originally created by @DDDU123 on GitHub (Jul 6, 2024). ### 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 [search for existing issues](https://github.com/langgenius/dify/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] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:) - [X] Please do not modify this template :) and fill in all the required fields. ### Dify version 0.6.12-fix1 ### Cloud or Self Hosted Cloud ### Steps to reproduce I got this error message when running the HTTP node: "authorization config header is required." But everything was working fine before yesterday, and I haven't made any changes to the authorization. ![企业微信截图_20240706163352](https://github.com/langgenius/dify/assets/148761774/a81131c9-001a-4351-a4d0-1fdb660db49d)![企业微信截图_20240706163345](https://github.com/langgenius/dify/assets/148761774/e57da0c1-4ef2-4a10-a4b5-b42b80401c51) ### ✔️ Expected Behavior _No response_ ### ❌ Actual Behavior _No response_
yindo added the 🐞 bug label 2026-02-21 18:06:42 -05:00
yindo closed this issue 2026-02-21 18:06:42 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Jul 6, 2024):

Hello, @DDDU123! I'm here to help you with any bugs, questions, or contributions you have for the repository. Let's tackle this issue together!

To resolve the "authorization config header is required" error in Dify version 0.6.12-fix1, ensure that the authorization configuration is correctly set up in your HTTP node. Specifically, you need to provide the required header or API key based on the selected authorization type.

Here is a step-by-step guide to ensure the correct configuration:

  1. Open the Authorization Modal: Ensure that the authorization modal is displayed by setting isShow to true.

  2. Select Authorization Type: Choose the appropriate authorization type (e.g., no-auth or api-key) using the RadioGroup component.

  3. Configure API Key or Header:

    • If you select api-key as the authorization type, you need to further specify the API type (e.g., basic, bearer, or custom).
    • For custom API type, you must provide a header value.
    • For other API types, you need to provide an API key.
  4. Save the Configuration: Ensure that the configuration is saved by clicking the save button, which triggers the handleConfirm function.

Here is the relevant code snippet to guide you through the process:

const handleAuthTypeChange = useCallback((type: string) => {
  const newPayload = produce(tempPayload, (draft: AuthorizationPayloadType) => {
    draft.type = type as AuthorizationType
    if (draft.type === AuthorizationType.apiKey && !draft.config) {
      draft.config = {
        type: APIType.basic,
        api_key: '',
      }
    }
  })
  setTempPayload(newPayload)
}, [tempPayload, setTempPayload])

const handleAuthAPITypeChange = useCallback((type: string) => {
  const newPayload = produce(tempPayload, (draft: AuthorizationPayloadType) => {
    if (!draft.config) {
      draft.config = {
        type: APIType.basic,
        api_key: '',
      }
    }
    draft.config.type = type as APIType
  })
  setTempPayload(newPayload)
}, [tempPayload, setTempPayload])

const handleAPIKeyOrHeaderChange = useCallback((type: 'api_key' | 'header') => {
  return (e: React.ChangeEvent<HTMLInputElement>) => {
    const newPayload = produce(tempPayload, (draft: AuthorizationPayloadType) => {
      if (!draft.config) {
        draft.config = {
          type: APIType.basic,
          api_key: '',
        }
      }
      draft.config[type] = e.target.value
    })
    setTempPayload(newPayload)
  }
}, [tempPayload, setTempPayload])

const handleConfirm = useCallback(() => {
  onChange(tempPayload)
  onHide()
}, [tempPayload, onChange, onHide])

Ensure that you provide the necessary api_key or header value based on the selected API type to avoid the "authorization config header is required" error. According to the HttpRequestNodeData class in the Dify codebase, the Authorization configuration must be a dictionary if the type is not no-auth. This validation ensures that the correct configuration is provided:

class Authorization(BaseModel):
    class Config(BaseModel):
        type: Literal[None, 'basic', 'bearer', 'custom']
        api_key: Union[None, str] = None
        header: Union[None, str] = None

    type: Literal['no-auth', 'api-key']
    config: Optional[Config] = None

    @field_validator('config', mode='before')
    @classmethod
    def check_config(cls, v: Config, values: ValidationInfo):
        if values.data['type'] == 'no-auth':
            return None
        else:
            if not v or not isinstance(v, dict):
                raise ValueError('config should be a dict')
            return v

Make sure your configuration adheres to these requirements to resolve the error [1][2].

To continue talking to Dosu, mention @dosu.

@dosubot[bot] commented on GitHub (Jul 6, 2024): <!-- Greeting --> Hello, @DDDU123! I'm here to help you with any bugs, questions, or contributions you have for the repository. Let's tackle this issue together! <!-- Answer --> To resolve the "authorization config header is required" error in Dify version 0.6.12-fix1, ensure that the authorization configuration is correctly set up in your HTTP node. Specifically, you need to provide the required header or API key based on the selected authorization type. Here is a step-by-step guide to ensure the correct configuration: 1. **Open the Authorization Modal**: Ensure that the authorization modal is displayed by setting `isShow` to `true`. 2. **Select Authorization Type**: Choose the appropriate authorization type (e.g., `no-auth` or `api-key`) using the `RadioGroup` component. 3. **Configure API Key or Header**: - If you select `api-key` as the authorization type, you need to further specify the API type (e.g., `basic`, `bearer`, or `custom`). - For `custom` API type, you must provide a header value. - For other API types, you need to provide an API key. 4. **Save the Configuration**: Ensure that the configuration is saved by clicking the save button, which triggers the `handleConfirm` function. Here is the relevant code snippet to guide you through the process: ```tsx const handleAuthTypeChange = useCallback((type: string) => { const newPayload = produce(tempPayload, (draft: AuthorizationPayloadType) => { draft.type = type as AuthorizationType if (draft.type === AuthorizationType.apiKey && !draft.config) { draft.config = { type: APIType.basic, api_key: '', } } }) setTempPayload(newPayload) }, [tempPayload, setTempPayload]) const handleAuthAPITypeChange = useCallback((type: string) => { const newPayload = produce(tempPayload, (draft: AuthorizationPayloadType) => { if (!draft.config) { draft.config = { type: APIType.basic, api_key: '', } } draft.config.type = type as APIType }) setTempPayload(newPayload) }, [tempPayload, setTempPayload]) const handleAPIKeyOrHeaderChange = useCallback((type: 'api_key' | 'header') => { return (e: React.ChangeEvent<HTMLInputElement>) => { const newPayload = produce(tempPayload, (draft: AuthorizationPayloadType) => { if (!draft.config) { draft.config = { type: APIType.basic, api_key: '', } } draft.config[type] = e.target.value }) setTempPayload(newPayload) } }, [tempPayload, setTempPayload]) const handleConfirm = useCallback(() => { onChange(tempPayload) onHide() }, [tempPayload, onChange, onHide]) ``` Ensure that you provide the necessary `api_key` or `header` value based on the selected API type to avoid the "authorization config header is required" error. According to the `HttpRequestNodeData` class in the Dify codebase, the `Authorization` configuration must be a dictionary if the type is not `no-auth`. This validation ensures that the correct configuration is provided: ```py class Authorization(BaseModel): class Config(BaseModel): type: Literal[None, 'basic', 'bearer', 'custom'] api_key: Union[None, str] = None header: Union[None, str] = None type: Literal['no-auth', 'api-key'] config: Optional[Config] = None @field_validator('config', mode='before') @classmethod def check_config(cls, v: Config, values: ValidationInfo): if values.data['type'] == 'no-auth': return None else: if not v or not isinstance(v, dict): raise ValueError('config should be a dict') return v ``` Make sure your configuration adheres to these requirements to resolve the error <sup>[[1]](https://github.com/langgenius/dify/blob/main/web/app/components/workflow/nodes/http/components/authorization/index.tsx)</sup><sup>[[2]](https://github.com/langgenius/dify/blob/main/api/core/workflow/nodes/http_request/entities.py)</sup>. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
Author
Owner

@75py commented on GitHub (Jul 6, 2024):

I found a workaround for this issue. Instead of setting the Bearer authorization as shown in the first image, configure it using the Custom option as shown in the second image. This method works successfully.

Configuration Method Image
Bearer Authorization (does not work) bearer
Custom Authorization (works) custom
@75py commented on GitHub (Jul 6, 2024): I found a workaround for this issue. Instead of setting the Bearer authorization as shown in the first image, configure it using the Custom option as shown in the second image. This method works successfully. | Configuration Method | Image | |------------------------|--------------------------------------------| | Bearer Authorization (does not work) | <img width="464" alt="bearer" src="https://github.com/langgenius/dify/assets/3153211/080cd1bd-69f6-47db-a2ff-eaaac2aa8d83"> | | Custom Authorization (works) | <img width="464" alt="custom" src="https://github.com/langgenius/dify/assets/3153211/2ad80854-0d2e-44c9-8772-88551d6abf4f"> |
Author
Owner

@DDDU123 commented on GitHub (Jul 6, 2024):

我找到了解决此问题的方法。不要像第一张图所示那样设置 Bearer 授权,而是使用第二张图所示的自定义选项进行配置。此方法成功运行。

配置方法 图像
持有人授权(无效) 持票人
自定义授权(作品) 风俗

Yes, it worked fine after I followed your instructions. Thanks! But what puzzles me is that it used to work with Bearer Authorization before. Maybe a new version of Dify introduced a bug.

@DDDU123 commented on GitHub (Jul 6, 2024): > 我找到了解决此问题的方法。不要像第一张图所示那样设置 Bearer 授权,而是使用第二张图所示的自定义选项进行配置。此方法成功运行。 > > 配置方法 图像 > 持有人授权(无效) <img alt="持票人" width="464" src="https://private-user-images.githubusercontent.com/3153211/346266201-080cd1bd-69f6-47db-a2ff-eaaac2aa8d83.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjAyNjA4MDcsIm5iZiI6MTcyMDI2MDUwNywicGF0aCI6Ii8zMTUzMjExLzM0NjI2NjIwMS0wODBjZDFiZC02OWY2LTQ3ZGItYTJmZi1lYWFhYzJhYThkODMucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDcwNiUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA3MDZUMTAwODI3WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9ZDRmMDI4YWVkMmNlZjMyYzZhNDliZGZjOWJiNTZhOWNiZjVhNDMzODg0MDgxMTIzYThiOTg0MWRlYWFlNDk1OSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.fcmxK9jxo9Circi6v4PwRtHtszw_nYbW_Cw4cEqrAa0"> > 自定义授权(作品) <img alt="风俗" width="464" src="https://private-user-images.githubusercontent.com/3153211/346266213-2ad80854-0d2e-44c9-8772-88551d6abf4f.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjAyNjA4MDcsIm5iZiI6MTcyMDI2MDUwNywicGF0aCI6Ii8zMTUzMjExLzM0NjI2NjIxMy0yYWQ4MDg1NC0wZDJlLTQ0YzktODc3Mi04ODU1MWQ2YWJmNGYucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDcwNiUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA3MDZUMTAwODI3WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9OWUzNjdiMjVkNDY2Mjg2N2E5ODdkY2JkOWJjZjNiMzJjMzdkMDBjMDczYTc4MGNhY2E0NTBiOGFmYmM4ZGQ5ZCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.Y-LGWnh705taTJqkZnPNa_mSQ5QLDLY9zcwTNhqm9Gs"> Yes, it worked fine after I followed your instructions. Thanks! But what puzzles me is that it used to work with Bearer Authorization before. Maybe a new version of Dify introduced a bug.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#4478