Vonage / vonage-node-sdk

Vonage API client for Node.js. API support for SMS, Voice, Text-to-Speech, Numbers, Verify (2FA) and more.
Apache License 2.0
375 stars 178 forks source link

Messages CLI not working #869

Closed fstovarr closed 7 months ago

fstovarr commented 9 months ago

https://github.com/Vonage/vonage-node-sdk/blob/65d4bcf525661f1f35161980d0ad6dd5fafcf81a/packages/messages/lib/messages.ts#L21 This line is not allowing to set the Basic auth type when using key/secret.

Therefore, the Authorization headers are not being set in the requests, and the API's answer is always being:

data: {
  title: 'Unauthorised',
  detail: "Request header 'Authorization' missing"
}
manchuck commented 9 months ago

@fstovarr can you provide a code sample of how you are creating messages client?

fstovarr commented 9 months ago

@manchuck

 const vonage = new Vonage(
      new Auth({
        apiKey: config.vonage.apiKey,
        apiSecret: config.vonage.apiSecret,
      })
    )

    const res = await vonage.messages.send(
      new SMS({
        to: to,
        from: FROM,
        text: text,
      })
    )
manchuck commented 7 months ago

@fstovarr the messages API does not allow Basic auth. You will need to create an application and import the private key. If you only have an API Key/Secret, then you can use the legacy SMS api vonage.sms.send( ...) If you have any more questions, feel free to reach out in our community Slack