【发布时间】:2017-06-08 21:48:19
【问题描述】:
我尝试使用由 swagger-codegen 创建的框架,但我不明白如何将授权令牌传递给我的 API 方法。
例如我们可以使用示例 Petstore:https://github.com/swagger-api/swagger-codegen/blob/master/samples/client/petstore/android/httpclient/docs/UserApi.md#updateUser
如何将授权令牌添加到我的请求标头(我将从我之前对 AuthorizationAPI 的请求中收到的令牌)?
也许我不了解 Android 的 swagger-codegen 的授权流程。
UserApi apiInstance = new UserApi();
User body = new User(); // User | Created user object
try {
apiInstance.createUser(body); // here I will receive error unauhorized
} catch (ApiException e) {
System.err.println("Exception when calling UserApi#createUser");
e.printStackTrace();
}
【问题讨论】:
标签: java swagger swagger-codegen