How to authenticate nexmo voice client?

  nexmo, python, python-3.x, ssl, ssl-certificate

I am trying to make an outbound call using Nexmo (Vonage) API. To access the API, I am required to authenticate my client using an application id and a private key (given to me as a .key file).

The application id was specified as a string and the private key was specified as a path.

client = nexmo.Client(application_id = 'xxxxxx-xxxxxxx', private_key = "C:pathtofolderprivate.key")

I get the following error.

  File "", line 30, in <module>
    'ncco': ncco
  File "", line 606, in __call__
    args, kwargs)
  File "", line 285, in wrapper_function
    return wrapped_(*args_, **kwargs_)
  File "", line 427, in create_call
    return self._jwt_signed_post("/v1/calls", params or kwargs)
  File "", line 719, in _jwt_signed_post
    self.api_host(),, json=params, headers=self._headers())
  File "", line 742, in _headers
    return dict(self.headers, Authorization=b"Bearer " + token)
TypeError: can't concat str to bytes

Source: Python Questions

One Reply to “How to authenticate nexmo voice client?”

  • i’m to get this error
    So, i’m just change this
    return dict(self.headers, Authorization=b"Bearer " + token)
    on this
    return dict(self.headers, Authorization=b"Bearer " + token.encode('ascii'))
    and all work good.