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

Encrypt Password not working #348

Open
gonza1207 opened this issue Mar 7, 2025 · 6 comments
Open

Encrypt Password not working #348

gonza1207 opened this issue Mar 7, 2025 · 6 comments

Comments

@gonza1207
Copy link

I'm authenticating with my demo account. If I choose to not encrypt password, the login works and can use the API. If I just change the value of encrypt password to True, then I get authentication error.
I have tried using the API Companion from IG on web, and Im able to authenticate encrypting the password and the same credentials.

Everything indicates that the password encryption using the encryption key is wrong, but I don't understand how anyone else doesn't have this problem.

ig_service = IGService(config.username, config.password, config.api_key, acc_number=config.acc_number)
ig = ig_service.create_session(version='3', encryption=False)

That works.

ig_service = IGService(config.username, config.password, config.api_key, acc_number=config.acc_number)
ig = ig_service.create_session(version='3', encryption=True)

That fails with:

{"errorCode":"error.security.invalid-details"}
@bug-or-feature
Copy link
Member

Encrypt password works fine. See the integration test runs here

Much more likely you have mixed up username, password, API key, account name, LIVE or DEMO in your code somewhere

@gonza1207
Copy link
Author

gonza1207 commented Mar 10, 2025

There are no tests for version=3 of the API with encryptPassword=true. I think I figured the problem out. I'm passing encrypt=True but that is only for version=2 of the API. Version=3 doesn't have encrypt=True and loads the credentials in plain text.

Do you use version=2 or version=3? I was able to authenticate with version=2 using encrypt password but then the open position call doesn't do anything, but it does so with version=3 unencrypted.

Is anyone actively trading with this client? Thanks.

@gonza1207
Copy link
Author

If I use version 3, which apparently doesn't need encrypt password, will that password by encrypted by default due ot it being HTTPS? If so, then why do we have the encrypt password for version2 that also uses HTTPS?

@bug-or-feature
Copy link
Member

You're right, v3 doesn't support encrypted password. See IG docs here

Have a look at error "error.public-api.failure.encryption.required" on the same page. That implies encryption was introduced to comply with regulatory requirements in Singapore.

I have traded with the API using v3 sessions

@gonza1207
Copy link
Author

I have traded with the API using v3 sessions

So you're saying that using encrypt password = false should have no security risk then?

@bug-or-feature
Copy link
Member

I use v3 sessions for the reason mentioned in the last paragraph of this answer

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