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

Support the IdentityProvider API in this client #38

Open
robotdan opened this issue Aug 28, 2020 · 2 comments
Open

Support the IdentityProvider API in this client #38

robotdan opened this issue Aug 28, 2020 · 2 comments

Comments

@robotdan
Copy link
Member

robotdan commented Aug 28, 2020

Currently due to the serialization / de-serialization complexity of the IdP APIs, they are omitted from this client.

Here are the APIs we are skipping at the moment:
https://github.com/FusionAuth/fusionauth-client-builder/blob/462c2ca09bb291581164f383428ae276645ace55/src/main/client/go.client.ftl#L186

If we could figure out how to make this work in Go, we would add them.

Here is an example solution provided by @MCBrandenburg https://play.golang.org/p/7ZBAbrDo98w

@matthewhartstonge
Copy link

matthewhartstonge commented Mar 23, 2021

Here's my sample solution: https://play.golang.org/p/RX_mRBsSUQD

Generally, Gophers tend to code everything into the expected payload, with the expectation that developers are (...hopefully...) smart enough to switch/case on type for the fields they require directly.

As long as you API docs specify this, then it's a case of Read The Manual if they use the SDK wrong.

Having to step through and unmarshal bits of a response manually is much more painful than having all the data there ready to use.

For truly custom user JSON, (for example, user.Data) where you currently have map[string]interface{} you could use json.RawMessage, that way developers themselves can marshal/unmarshal into their required types as needed. Which means the main bit (what FA) cares about is marshalled out into useable data.

(For user data I ended up json.Marshal'ing user.Data to JSON so I could then json.Unmarshal to MyType{} as map[string]interface{} is a pain to work with in terms of complex objects/switch casing/type switch casing and/or marshalling each piece out, I then do the marshal/unmarshal dance in reverse to get me a map[string]interface{} before pushing the data back up 😄 so json.RawMessage would be a win for me here too 👍)

Hope that helps add to the conversation! 🎉

@robotdan
Copy link
Member Author

Thanks for the great detail and suggestions @matthewhartstonge - appreciate it!!

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