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

Adding OAuth token support #203

Merged
merged 1 commit into from
Feb 25, 2020

Conversation

chrisforrette
Copy link
Contributor

I tried to use GetCurrentUser from #199 and was getting 401s and realized the Authorization header was being hard-coded and needs to be formatted differently for OAuth tokens, per the documentation here:

https://v2.developer.pagerduty.com/docs/oauth-2-functionality-client-secret#section-using-an-access-token

This PR:

  • Adds an authType field to the Client struct, whose value can be apiToken (default) or oauthToken
  • Updates NewClient method to set authType to apiToken
  • Adds NewOAuthClient method that is identical NewClient but sets authType to oauthToken
  • Adds a switch statement in the do method to set the Authorization header appropriately based on the Client authType value.

Copy link
Contributor

@stmcallister stmcallister left a comment

Choose a reason for hiding this comment

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

This is great! Thanks for adding this!

@stmcallister stmcallister merged commit d689b61 into PagerDuty:master Feb 25, 2020
@chrisforrette chrisforrette deleted the add-oauth-client branch February 25, 2020 23:33
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.

2 participants