我使用 autorest 生成TypeScript客户端以访问RESTful Web服务 . 所有REST api都会查找用于身份验证的承载令牌,但我没有找到将令牌传递给自动生成的TypeScript客户端的方法 .
我确实尝试过搜索autorest文档 . 看起来我需要使用ServiceClientCredentials,但我没有找到任何示例代码 .
有谁知道如何在TypeScript中使用ServiceClientCredentials?
我使用以下命令生成TypeScript客户端
autorest --input-file=restapi.json --typescript --output-folder=./output --package-name="test-api" --package-version="0.1.0" --generate-metadata=true --add-credentials=true
1 回答
我找到了答案 . 我需要创建
TokenCredentials
的对象并在自动生成的客户端中传递它