Comments (7)
You may be hitting the Rate Limits of our API. Updates to users are limited to 30 requests per minute. Additionally, the SDK logic will grab the oauth_key
for you if it is invalid which is another rate-limited call.
from synapsego.
Hi @nathanielniosco,
Thanks for your reply. I'm only doing it as a one shot test, and I have tried only few time per minutes (not 30 ofc). I already knew that Synapsefi API has a rate limits :s.
Is it working on your side ? doing a GetUser() to retrieve the user you want to manage, and then, straightforward an Update() on it ?
from synapsego.
I did test this earlier with the by calling GetUser() and then an immediate Update() on the user. I forgot to mention that. Are you still encountering this error?
from synapsego.
Hi @nathanielniosco
Yes, I still have the issue. Here is the full code (test go file) that I'm using, which is really simple.
func TestLib(t *testing.T) {
userID := "MY_ID"
cfg := LoadConfig()
client := synapse.New(
cfg.ClientID,
cfg.ClientSecret,
"127.0.0.1",
cfg.Fingerprint,
)
// Get the user
user, err := client.GetUser(userID, client.IP, client.Fingerprint)
if err != nil {
t.Fatal(err)
}
// Update the documents
body := `{
"documents":[{
}]
}`
user, err = user.Update(body)
if err != nil {
t.Fatal(err)
}
}
The error is still the same
HTTP_CODE 429 ERROR_CODE 429 Too many requests hit the API too quickly.
I don't have any trouble for the other endpoints, such as CreateUser(), CreateNode() ... this is the only one.
Am I doing something wrong ?
Thanks in advance,
from synapsego.
EDIT: I have tried something more, and I think that the issue is coming from the "Authenticate" management.
I tried to log the AuthKey value after the GetUser(). Since the user has not been authenticated, it is empty. So far so good. Then, trying to Update() the user, It needs to be authenticated to execute properly the request. This is normally handled in the users.go file, line 54:
switch err.(type) {
case *IncorrectUserCredentials:
_, err = u.Authenticate(`{ "refresh_token": "` + u.RefreshToken + `" }`)
if err != nil {
return nil, err
}
u.request.authKey = u.AuthKey
return u.do(method, url, data, params)
So I tried to log, after the Update() call, the AuthKey value, and it is still empty. So I am wondering if we reaching that part of code, or if there is something else.
Here is a the test code
func TestLib(t *testing.T) {
userID := "MY_ID"
cfg := LoadConfig()
client := synapse.New(
cfg.ClientID,
cfg.ClientSecret,
"127.0.0.1",
cfg.Fingerprint,
true,
true,
)
// Get the user
user, err := client.GetUser(userID, client.IP, client.Fingerprint)
if err != nil {
t.Fatal(err)
}
log.Info("RefreshToken : ", user.RefreshToken)
log.Info("OAuthKey : ", user.AuthKey)
// Update the documents
body := `{
"documents":[{
}]
}`
user, err = user.Update(body)
log.Info("RefreshToken : ", user.RefreshToken)
log.Info("OAuthKey : ", user.AuthKey)
if err != nil {
t.Fatal(err)
}
}
I decided to Authenticate the user by my own, before doing the Update(), and it is working. Here is the test code with authenticate:
func TestLib(t *testing.T) {
userID := "MY_ID"
cfg := LoadConfig()
client := synapse.New(
cfg.ClientID,
cfg.ClientSecret,
"127.0.0.1",
cfg.Fingerprint,
true,
true,
)
// Get the user
user, err := client.GetUser(userID, client.IP, client.Fingerprint)
if err != nil {
t.Fatal(err)
}
log.Info("RefreshToken : ", user.RefreshToken)
log.Info("OAuthKey : ", user.AuthKey)
_, err = user.Authenticate(`{ "refresh_token": "` + user.RefreshToken + `" }`)
// Update the documents
body := `{
"documents":[{
}]
}`
user, err = user.Update(body)
log.Info("RefreshToken : ", user.RefreshToken)
log.Info("OAuthKey : ", user.AuthKey)
if err != nil {
t.Fatal(err)
}
}
Maybe I'm totally wrong, @nathanielniosco can you double check ?
Can it be related to fingerprint ?
Thanks in advance :)
from synapsego.
EDIT: There are some mistake done when udpating the request:
in users.go, line 37
u.request = u.request.updateRequest(u.request.clientID, u.request.clientSecret, u.request.fingerprint, u.request.ipAddress, u.AuthKey)
and in the request.go, line 23
func (req *Request) updateRequest(clientID, clientSecret, ipAddress, fingerprint string, authKey ...string) Request {
}
There is a switch between IP & fingerprint parameters.
I forked and tried on my side and it is working now. Have created a PR for this one.
To verify on your side as well maybe @nathanielniosco
:)
from synapsego.
Thank you for the catch! It's preferred to keep fingerprint
first followed by ip_address
. Parameter switching occurred in other parts of the code. Please note that when creating a new client, the order is now:
client := synapse.New(
CLIENT_ID,
CLIENT_SECRET,
FINGERPRINT, // swapped with ip_address
IP_ADDRESS, // swapped with ip_address
)
This will also affect GetUser
and CreateUser
methods. See c581606 for changes.
Closing this issue.
from synapsego.
Related Issues (11)
- Create and authenticate user HOT 1
- client.GetPublicKey doesn't work HOT 3
- client.CreateUser incorrect Fingerprint / IPAddress HOT 2
- Create Node with ACH-US login HOT 2
- *Request.updateRequest method is not updating the receiver instance
- client.GetUsers not calling buildUrl
- IncorrectValues error handling HOT 1
- Library should not panic
- Responses should just be a []byte HOT 2
- user.GetStatements stuck in authenticate loop HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from synapsego.