如何在卡萨布兰卡 REST API 中检索授权标头
How do you retrieve the authorization header in Casablanca REST API
>我有以下函数来检查授权标头。
bool is_authorized(http_request request)
{
bool isAuthorized = false;
int bitmask;
int maskResult;
ApplicationAuthorization returned_auth;
ApplicationAuthorizations authorizations;
char authHeader[255];
if (!request.headers().has(header_names::authorization)) return false;
returned_auth = authorizations.GetAuthorization(to_string_t("token {368EB89B-8A5E-5CF3-07AB-C16961D1A392}"));
bitmask = 1 << DATAENGINE;
maskResult = (returned_auth.GetApplicationId() & bitmask);
isAuthorized = maskResult;
return isAuthorized;
}
目前,我已经放置了一个临时令牌仅用于测试,虽然我可以看到如何检查授权标头是否存在 - 目前尚不清楚如何检索该标头的值。
任何人都知道如何使用Casablanca REST API检索标头。
标头可通过调用请求对象的 headers() 函数获得。以下代码将授权标头放在 authHeader 局部变量中。
string_t authHeader;
if (!request.headers().has(header_names::authorization)) return false;
headers = request.headers();
authHeader = headers[header_names::authorization];
相关文章:
- 使用VerQueryValue检索应用程序的文件描述
- 是否可以从格式字符串中检索"width"
- 使用 pqxx 将 std::vector 存储在 postgresql 中,并从数据库中检索它
- 如何在QByteArray中放置和检索位字段而不会感到痛苦?
- 如何在Qt中从数据库中检索二进制数据?
- 如何从C++代码中检索 QML 的文本字段中的文本?
- 从 opencv c++ 中的矢量中检索固定的帧数
- 如何在不等待检索的情况下获取C++中的内存位置?
- 如何在 QTreeWidget 中检索特定项目的 mimeData?
- C++从字符串中检索几行
- 在数据库中插入和检索矩阵
- 两个垫子的 OpenCV 数据是相同的,但使用 Mat::at 检索时的值已损坏
- 使用 const char* 键映射 C++ 检索空值
- 打印从SQLite3数据库检索的数据C++与命令行中相同的方式
- 如何检索指向在单独线程上运行的函数的移动指针?
- 如何检索 Steamwork SDK 的当前版本
- 通过 host() 从 af::array 检索数据会导致错误的数据
- 无法从类中检索值
- 初始化类中的指针数组,并在另一个类中检索它
- 如何在卡萨布兰卡 REST API 中检索授权标头