我无法使用成功添加标题
// create a custom header
val header: io.grpc.Metadata = io.grpc.Metadata()
val auth: io.grpc.Metadata.Key<String> = io.grpc.Metadata.Key.of("authorization", io.grpc.Metadata.ASCII_STRING_MARSHALLER)header.put(auth, "barer "+ AWSMobileClient.getInstance().tokens.idToken.tokenString);
Stub = io.grpc.stub.MetadataUtils.attachHeaders(Stub, header)
正如Android建议的那样如何在grpc客户端中添加自定义标头?.
我得到: onError: io.grpc.StatusRuntimeException: UNAVAILABLE
在IOS中,我能够使用:
let authToken = "\(AWSCognitoUserPoolsSignInProvider.sharedInstance().getUserPool().token().result ?? "")"
let httpHeader: [(String, String)] = [("Authorization", authToken)]
let header = HPACKHeaders(httpHeader)
callOptions = CallOptions(customMetadata: header, timeLimit: .none, messageEncoding: .disabled , requestIDProvider: .none, requestIDHeader: nil, cacheable: false)
let req = Cilix_Api_GetVersionRequest()
let request = self.client?.getVersion(req, callOptions: callOptions)
任何建议将被认真考虑