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

[Go] Update to use oauth2 #6618

Closed
grokify opened this issue Oct 4, 2017 · 2 comments
Closed

[Go] Update to use oauth2 #6618

grokify opened this issue Oct 4, 2017 · 2 comments

Comments

@grokify
Copy link

grokify commented Oct 4, 2017

Description

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:

  • Change Configuration.Transport type to http.RoundTripper from *http.Transport
  • Change api_client.go to use "gopkg.in/go-resty/resty.v1" from "gopkg.in/go-resty/resty.v0"
Swagger-codegen version

https://github.com/grokify/ringcentral-sdk-go-scg/blob/master/swagger_ringcentral_codegen_version.txt

$ 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
Swagger declaration file content or url

https://github.com/grokify/ringcentral-sdk-go-scg/blob/master/swagger_ringcentral_spec.json

Command line used for generation

https://github.com/grokify/ringcentral-sdk-go-scg/blob/master/swagger_ringcentral_command.sh

Steps to reproduce

Run this code with an unmodified client SDK:

https://github.com/grokify/ringcentral-sdk-go-scg/blob/master/examples/get_extension/get_extension.go

Related issues/PRs

not found

Suggest a fix/enhancement
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.

@wing328
Copy link
Contributor

wing328 commented Oct 5, 2017

@grokify can you check the latest master (2.3.0), which has Go client refactored and OAuth2 support?

@grokify
Copy link
Author

grokify commented Dec 18, 2017

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.
  • query parameters are now a map[string]interface{} instead of a sequence of function parameters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants