Skip to content

feat: oauth feature #267

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

feat: oauth feature #267

wants to merge 2 commits into from

Conversation

manisha1997
Copy link
Contributor

Fixes

Oauth feature

Checklist

  • I acknowledge that all my contributions will be made under the project's license
  • I have made a material change to the repo (functionality, testing, spelling, grammar)
  • I have read the Contribution Guidelines and my PR follows them
  • I have titled the PR appropriately
  • I have updated my branch with the main branch
  • I have added tests that prove my fix is effective or that my feature works
  • I have added the necessary documentation about the functionality in the appropriate .md file
  • I have added inline documentation to the code I modified

If you have questions, please file a support ticket, or create a GitHub Issue in this repository.

Comment on lines +16 to 20
"github.com/twilio/twilio-go/oauth"

"github.com/pkg/errors"
"github.com/twilio/twilio-go/client/form"
)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: import ordering.

Comment on lines +44 to +46
func NewClientCredentials(grantType, clientId, clientSecret string, handler RequestHandler) *ClientCredentials {
return &ClientCredentials{GrantType: grantType, ClientId: clientId, ClientSecret: clientSecret, RequestHandler: handler}
}
Copy link

@light-bringer light-bringer Mar 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: not much readable, can we try running a linter (preferably go-fumpt)

@@ -0,0 +1 @@
package twilio
Copy link

@light-bringer light-bringer Mar 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: can we please include tests and try to have the patch coverage.

tokenManager: tokenManager,
}
}
func NewTokenAuth(grantType, clientId, clientSecret, code, audience, refreshToken, scope string) *TokenAuth {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, this is not being used anywhere.

tokenManager *TokenManager
}

func NewTokenAuthInitializer(token string, tokenManager *TokenManager) *TokenAuth {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can rename NewTokenAuthInitializer to NewTokenAuth. Any func prefixed with New is already considered as a constructor func

}
}

func (t *TokenAuth) FetchToken(c client.RequestHandler) (string, error) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good to have func level comment to get quick glimpse of what func does and also helps when func is referenced in other packages.

return true
}

if claims, ok := token.Claims.(jwt.MapClaims); ok {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need to catch err here if token.Claims do not assert to jwt.MapClaims ? in what case that can happen, need more info here

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

Successfully merging this pull request may close these issues.

3 participants