Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Messages API (SMS) Authentication Failed. Check you're using a valid authentication method #289

Closed
dlewis2017 opened this issue Dec 15, 2023 · 5 comments

Comments

@dlewis2017
Copy link

Authentication failed. Check you're using a valid authentication method.

Expected Behavior

I expected to be able to initialize Client with application_id and private_key filepath and then send an SMS with messages API.

Current Behavior

I get the error mentioned above : vonage.errors.AuthenticationError: Authentication failed. Check you're using a valid authentication method.

Possible Solution

Seems the local _application_id isn't saving properly so when its checked for here it doesn't exist even though application_id does exist on client.

Steps to Reproduce (for bugs)

Follow tutorial

  1. Load client client = Client(application_id=application_id, private_key=private_key_file)
  2. send message client.messages.send_message({ "channel": "sms", "message_type": "text", "text":body, "from":from_, "to":to })
  3. Error produced

Context

I am trying to follow along with the tutorials and send an SMS via Messages API but getting an authentication error. I've been able to receive messages using messages API webhooks and send messages with SMS API.

Your Environment

  • Version used: 4.0.0b0 (pre-release)
  • Environment name and version (e.g. language and server version): python 3.10.6,
  • Operating System and version: Windows 11
@maxkahan
Copy link
Collaborator

Hi, the beta version you're using didn't fix this bug, I will probably yank that release. The purpose of it was to expose Video API functionality to developers who wanted early access, but it became out-of-date and has since been superseded by the release of v3.12.0.

Things should work as expected with v3.12.0, please give that one a try!

@dlewis2017
Copy link
Author

dlewis2017 commented Dec 18, 2023

Hi @maxkahan , thanks for the reply. So using 3.12.0 doesn't work because I have a version conflict that seems to be resolved in v4.0.0b0. The error I get is:

vonage 3.12.0 requires pydantic==1.*,>=1.10, but you have pydantic 2.5.2 which is incompatible.

We need the latest version of pydantic and other pydantic libraries (like pydantic-settings) require a later version of pydantic (2.*+ I think)

Here are some more errors I got along the way:

when downgrading to Vonage v 3.12.0:
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts. pydantic-settings 2.0.0 requires pydantic>=2.0b3, but you have pydantic 1.10.13 which is incompatible.

and when trying to run my application with the above, I get the issue: ModuleNotFoundError: No module named 'pydantic._internal' I imagine because pydantic-settings is looking for that module in pydantic, but older versions of pydantic aren't compatible

So, overall, if possible, I think upgrading pydantic to at least version 2.* should help. Would that be possible?

@dlewis2017
Copy link
Author

dlewis2017 commented Dec 18, 2023

I don't have permission to create a branch here but I made a few changes locally that seemed to enable my application to run properly @maxkahan (with a couple warnings). I'm not sure if there are additional changes needed to make sure this function for all users, or if there are tests that need to be updated. But it works for my needs so, the summary is:

  • Change some imports around:
from pydantic import BaseModel, Field, validator
from pydantic.types import  conint, constr, confloat, AnyType
  • change regex= in constr() to pattern=
  • add AnyType to type = Field(...) overrides in ncco.py, verify2.py, and connect_endpoints.py (where applicable). So type: AnyType = Field(...)
  • change const= in Field() to Literal=
  • remove or update pydantic version restriction in setup.py
  • update pydantic version in requirements.txt

I started a Draft pull request here: #290

@maxkahan
Copy link
Collaborator

Hi David, I started work to update the SDK to use Pydantic v2.x, but that required breaking changes so would have been rolled up into v4 of the SDK. I did some work on this on the old-4.x branch if you want to have a look, but it's incomplete. Priorities changed so I'm currently working on a full rewrite that will use Pydantic v2, as well as other significant changes. That won't be ready for a little while though. Hope this context is helpful!

@maxkahan
Copy link
Collaborator

Hi @dlewis2017 we've just released v3.13.0 with v2 support so that should solve this issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants