GitHub user dosubot[bot] added a comment to the discussion: When requesting a
Guest Token API, error code 422 is reported
<!-- Answer -->
The error code 422 with the message "Invalid header string: Expecting value:
line 1 column 1 (char 0)" when requesting a Guest Token via
`/api/v1/security/guest_token/` in Superset 4.0.1 typically indicates a problem
with the JSON payload or headers of your request. Here's how to address this
issue:
1. **Ensure Correct Content-Type**: Your request must include the header
`Content-Type: application/json` to inform the server that you are sending a
JSON payload.
2. **Validate JSON Payload**: The body of your POST request needs to be a valid
JSON string. According to the `GuestTokenCreateSchema`, it should include
`user`, `resources`, and `rls` fields. Here's an example of a well-formed JSON
payload:
```json
{
"user": {
"username": "guest_user",
"first_name": "Guest",
"last_name": "User"
},
"resources": [
{
"type": "dashboard",
"id": "1"
}
],
"rls": [
{
"dataset": 123,
"clause": "region='US'"
}
]
}
```
3. **Match Schema Requirements**: Double-check that your JSON payload strictly
adheres to the required schema, including all necessary fields and structure.
If you've verified the headers and payload are correct but still face issues,
it might be helpful to look into the server logs for more detailed error
messages. This could provide further insights into whether there's a
configuration issue or a problem with the `@protect()` mechanism itself.
<!-- Dosu Comment Footer -->
<details>
<summary>
#### Details
</summary>
**Sources**
-
[superset/security/api.py](https://github.com/apache/superset/blob/master/superset/security/api.py)
-
[superset/security/guest_token.py](https://github.com/apache/superset/blob/master/superset/security/guest_token.py)
-
[tests/integration_tests/security/api_tests.py](https://github.com/apache/superset/blob/master/tests/integration_tests/security/api_tests.py)
-
[superset/security/manager.py](https://github.com/apache/superset/blob/master/superset/security/manager.py)
-
[superset-frontend/packages/superset-ui-core/test/connection/SupersetClientClass.test.ts](https://github.com/apache/superset/blob/master/superset-frontend/packages/superset-ui-core/test/connection/SupersetClientClass.test.ts)
-
[superset/initialization/__init__.py](https://github.com/apache/superset/blob/master/superset/initialization/__init__.py)
-
[tests/integration_tests/security_tests.py](https://github.com/apache/superset/blob/master/tests/integration_tests/security_tests.py)
-
[superset/exceptions.py](https://github.com/apache/superset/blob/master/superset/exceptions.py)
-
[superset-frontend/packages/superset-ui-core/src/connection/SupersetClientClass.ts](https://github.com/apache/superset/blob/master/superset-frontend/packages/superset-ui-core/src/connection/SupersetClientClass.ts)
-
[superset-frontend/packages/superset-ui-core/test/connection/SupersetClient.test.ts](https://github.com/apache/superset/blob/master/superset-frontend/packages/superset-ui-core/test/connection/SupersetClient.test.ts)
<br/>
**About Dosu**
This response is meant to be useful and save you time. It is **not meant to be
a precise solution**, but rather a starting point for your own research.
Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is
irrelevant.
</details>
*To continue the conversation, mention @dosu.*
GitHub link:
https://github.com/apache/superset/discussions/33621#discussioncomment-13314210
----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]