synapsefi / synapsego Goto Github PK
View Code? Open in Web Editor NEWGo-based API wrapper for Synapse REST API
License: Apache License 2.0
Go-based API wrapper for Synapse REST API
License: Apache License 2.0
I want to create and authenticate user, I'm following documentation with this snippet:
client.CreateUser(body, "IP_ADDRESS", "FINGERPRINT")
u := client.GetUser(userID, "FINGERPRINT", "IP_ADDRESS")
u.Authenticate(body)
Which produces:
[Error] HTTP_CODE 400 ERROR_CODE 200
Invalid User IP.
Note, the error comes from the user.Authenticate
If I change the order of arguments passed to CreateUser
and GetUser
to:
client.CreateUser(body, "FINGERPRINT", "IP_ADDRESS")
u := client.GetUser(userID, "IP_ADDRESS", "FINGERPRINT")
u.Authenticate(body)
Things seams to be working correctly (oauth_key returned, no errors).
Things get more interesting, because the code for client
states that both, createUser and GetUser should use the same order of arguments (FINGERPRINT, IP_ADDRESS): https://github.com/SynapseFI/SynapseGo/blob/development/client.go#L267
So, the bug is:
Hi @nathanielniosco
I'm trying to add documents to a user. If a value is not well formatted (lets say Legal name) in the users.go file, do method, it will be blocked inside the switch case IncorrectValues with the following error
{
"error": {
"en": "Invalid field value supplied. Invalid name supplied. Please supply fullname."
},
"error_code": "400",
"http_code": "409",
"success": false
}
It loops trying to then GetRefreshToken(), Authenticate() until it reachs the API request limit rate. Maybe those kind of errors should be handled differently ?
Thanks in advance :)
Hey everyone,
I'm actually facing an issue trying to create a node using ACH-US login.
Here is the request i'm doing
body := `{
"type": "ACH-US",
"info":{
"bank_id":"synapse_good",
"bank_pw":"test1234",
"bank_name":"fake"
}
}`
node, err := user.CreateNode(body)
It fails with the following panic error
panic: interface conversion: interface {} is nil, not map[string]interface {} [recovered]
panic: interface conversion: interface {} is nil, not map[string]interface {}
goroutine 6 [running]:
testing.tRunner.func1(0xc0000d2200)
C:/Go/src/testing/testing.go:792 +0x38e
panic(0x7dd880, 0xc000060f30)
C:/Go/src/runtime/panic.go:513 +0x1c7
github.com/SynapseFI/SynapseGo.handleHTTPError(0xc000302000, 0x119, 0x600, 0x0, 0xc0002c8000)
D:/dev/go/pkg/mod/github.com/!synapse!f!i/[email protected]/error.go:213 +0x22a
github.com/SynapseFI/SynapseGo.(*Request).Post(0xc0001e9c68, 0xc000342e10, 0x47, 0x85e386, 0x75, 0x0, 0x0, 0x0, 0x570000c00000edc0, 0x32, ...)
D:/dev/go/pkg/mod/github.com/!synapse!f!i/[email protected]/request.go:88 +0x59d
github.com/SynapseFI/SynapseGo.(*User).do(0xc0001e9c20, 0x848339, 0x4, 0xc000342e10, 0x47, 0x85e386, 0x75, 0x0, 0x0, 0x0, ...)
D:/dev/go/pkg/mod/github.com/!synapse!f!i/[email protected]/users.go:43 +0x654
github.com/SynapseFI/SynapseGo.(*User).do(0xc0001e9c20, 0x848339, 0x4, 0xc000342e10, 0x47, 0x85e386, 0x75, 0x0, 0x0, 0x0, ...)
D:/dev/go/pkg/mod/github.com/!synapse!f!i/[email protected]/users.go:62 +0x530
github.com/SynapseFI/SynapseGo.(*User).CreateNode(0xc0001e9c20, 0x85e386, 0x75, 0x0, 0x0, 0x0, 0x0, 0x2f7, 0x501870)
It seems to come from the following part of error.go file:
func handleHTTPError(d []byte) error {
data := readStream(d)
errCode := data["error_code"].(string)
httpCode := data["http_code"].(string)
msg := data["error"].(map[string]interface{})["en"].(string)
return handleAPIError(errCode, httpCode, msg)
}
I tried with a standard DEPOSIT-US
, and it works.
Any idea? Maybe it is linked to "MFA" (I used sandbox values which doesn't require MFA, and it works)
Thanks in advance! :)
Successfully do client.GetUser(...)
followed by user.GetStatements("limit=1&per_page=1")
The get statements call gets stuck in an authentication loop throwing invalid authentication credentials error then attempting to oauth the user with .Authenticate ... forever.
Please help!
Running
client.GetPublicKey()
produces:
[Error] HTTP_CODE 404 ERROR_CODE 404
The endpoint requested does not exist. Please visit our API docs at https://docs.synapsefi.com to view all avaliable endpoints.
According to the docs, code etc. - this should work with the default scope ๐คทโโ๏ธ
Hi @nitharios ,
I'm actually trying to update documents of one of my user, but I'm stuck by an "Too many requests hit the API too quickly"
Here is my code:
// Get the user
user, err := client.GetUser(MYID, client.IP, client.Fingerprint)
// Create a request object to send (this is a struct for clearer mapping)
req := &request.UpdateUserRequest{}
...
// Marshaling the request
b, _ := json.Marshal(req)
// Updating the user
user, err = user.Update(string(b))
if err != nil {
panic(err)
}
It always panic with the following error:
HTTP_CODE 429 ERROR_CODE 429 Too many requests hit the API too quickly.
Any idea of what can be the issue ?
I'm actually in sandbox, and the client has been set for dev mode (not prod)
Thanks in advance ! :)
*Request.updateRequest
method instead of updating the receiver instance is returning a new one. Besides being confusing, when this method is called from *User.Authenticate
the Request
holded by User
is not getting updated with the new fingerprint
and ipAddress
.
I propose this solution #23
The GetUsers method in client.go does:
url := path["users"]
It should be:
url := buildURL(path["users"])
The library uses panic
in cases where it can return an error. Suggest in cases where multiple errors be returned to return the first error.
Lines 56 to 58 in 9d3ed7f
Lines 84 to 86 in 9d3ed7f
Lines 112 to 114 in 9d3ed7f
Lines 133 to 135 in 9d3ed7f
In this case I'd return an error here... Even better suggestion is to make the Response
just be a []byte
so that clients can marshal into their own structs, and get rid of readStream
entirely.
Lines 11 to 14 in 7a3e060
https://github.com/SynapseFI/SynapseGo/blob/master/client.go#L284
According to the code and docs, you need to provide FINGERPRINT and then IP_ADDRESS
The user created though has different fingerprint.
If you create user with:
client.CreateUser(body, "FINGERPRINT", "IP_ADDRESS")
the actual fingerprint is IP_ADDRESS
(go to uat-dashboard, and try logging in as the user with fingerprint 2fa)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.