I would like to use oauth2 with the codegen SDK. This is supported in resty v1.
Issues with codegen SDK reported here:
It seems like 2 changes are needed:
Configuration.Transport type to http.RoundTripper from *http.Transportapi_client.go to use "gopkg.in/go-resty/resty.v1" from "gopkg.in/go-resty/resty.v0"$ unzip -p swagger-codegen-cli.jar META-INF/MANIFEST.MF
Manifest-Version: 1.0
implementation-version: 2.2.3
Built-By: tony
Build-Jdk: 1.7.0_79
package: io.swagger
Created-By: Apache Maven 3.3.9
Main-Class: io.swagger.codegen.SwaggerCodegen
url: https://github.com/swagger-api/swagger-codegen/modules/swagger-co
degen-cli
mode: development
https://github.com/grokify/ringcentral-sdk-go-scg/blob/master/swagger_ringcentral_spec.json
https://github.com/grokify/ringcentral-sdk-go-scg/blob/master/swagger_ringcentral_command.sh
Run this code with an unmodified client SDK:
not found
| Item | old | new |
|------|-----|-------|
| Configuration.Transport type | *http.Transport | http.RoundTripper |
| resty dependency | gopkg.in/go-resty/resty.v0 | gopkg.in/go-resty/resty.v1 |
More testing is necessary to ensure resty.v1 is backward compatible with resty.v0 everywhere used.
@grokify can you check the latest master (2.3.0), which has Go client refactored and OAuth2 support?
Thanks @wing328!
I've verified v2.3.0 works for me using oauth2 with a http.Client created by oauth2.Config.Client() using an updated version of my go-aha client (https://github.com/grokify/go-aha). I'll update this and the other auto-generated SDKs I maintain.
I use something like the following now:
cfg := aha.NewConfiguration()
cfg.HTTPClient = client // generated by oauth2.Config.Client()
apiClient := aha.NewAPIClient(cfg)
featuresApi := apiClient.FeaturesApi
As a bonus, I noticed that a couple of things are much nicer in 2.3.0:
"type":"string", "format":"date" now results in a string instead of a time.Time.map[string]interface{} instead of a sequence of function parameters.
Most helpful comment
Thanks @wing328!
I've verified v2.3.0 works for me using oauth2 with a
http.Clientcreated byoauth2.Config.Client()using an updated version of mygo-ahaclient (https://github.com/grokify/go-aha). I'll update this and the other auto-generated SDKs I maintain.I use something like the following now:
As a bonus, I noticed that a couple of things are much nicer in 2.3.0:
"type":"string", "format":"date"now results in astringinstead of atime.Time.map[string]interface{}instead of a sequence of function parameters.