grpc-swift: Cannot authenticate via API key

I just cannot get authentication to work using Google Cloud (Speech) API keys. I’ve checked every example there is, yet my key is always rejected. I set the API key on the service metadata.

I’ve seen examples using…

  • X-Goog-Api-Key: swift grpc says invalid header. Error:
invalidMetadata
E0524 08:35:15.361115000 6176894976 call.cc:935] validate_metadata: {"created":"@1527143715.360978000","description":"Illegal header key","file":"/Users/era/Desktop/SpeechTest/Pods/gRPC-Core/src/core/lib/surface/validate_metadata.cc","file_line":43,"offset":0,"raw_bytes":"58 2d 47 6f 6f 67 2d 41 70 69 2d 4b 65 79 'X-Goog-Api-Key'"}
  • Authorization: Bearer + Token, swift grpc says invalid header
invalidMetadata
E0524 08:36:53.669556000 6135263232 call.cc:935] validate_metadata: {"created":"@1527143813.669152000","description":"Illegal header key","file":"/Users/era/Desktop/SpeechTest/Pods/gRPC-Core/src/core/lib/surface/validate_metadata.cc","file_line":43,"offset":0,"raw_bytes":"41 75 74 68 6f 72 69 7a 61 74 69 6f 6e 'Authorization'"}
  • X-Api-Key: seems to work as a header
successful, status permissionDenied: The request is missing a valid API key.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 37

Most upvoted comments

You need to remove thehttp://.

On 4. Nov 2018, at 08:22, zhaxylykbayev notifications@github.com wrote:

I’m printing it like print(“GRPC version (gRPC.version) - endpoint: (address)”) and getting GRPC version 6.0.0 - endpoint: http://195.133.196.155:7080 Also, if I change key “authorization” to “Authorization” there is some message:

E1104 13:19:10.640560000 4407625152 call.cc:935]
validate_metadata: {“created”:“@1541315950.640535000”,“description”:“Illegal header key”,“file”:“/Users/zhaxylykbayev/projects/aether/Pods/gRPC-Core/src/core/lib/surface/validate_metadata.cc”,“file_line”:43,“offset”:0,“raw_bytes”:“41 75 74 68 6f 72 69 7a 61 74 69 6f 6e ‘Authorization’”} — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.