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

feat: Support Bearer authorization callback in operations #63

Merged
merged 3 commits into from
Aug 7, 2019

Conversation

ffflorian
Copy link
Member

@ffflorian ffflorian commented Aug 7, 2019

This supports adding a callback to an endpoint which uses Bearer authorization:

deleteExchange = async (
  id: number,
  accessTokenCallback: () => Promise<string>
): Promise<void> => {
  const accessToken = await accessTokenCallback();
  const config: AxiosRequestConfig = {
    headers: {
      Authorization: `Bearer ${decodeURIComponent(accessToken)}`,
    },
    method: 'delete',
    url: `/api/v1/exchange/${id}`,
  };
  await this.apiClient.request(config);
};

I also moved from this.apiClient.[method]() to this.apiClient.request() and moved the method to the axios request configuration.

This closes #62.

@ffflorian ffflorian changed the title feat: Support Bearer auth callback feat: Support Bearer authorization callback Aug 7, 2019
src/Swaxios.test.ts Outdated Show resolved Hide resolved
Co-Authored-By: Benny Neugebauer <bn@bennyn.de>
@ffflorian ffflorian changed the title feat: Support Bearer authorization callback feat: Support Bearer authorization callback in operations Aug 7, 2019
@ffflorian ffflorian merged commit 44a830e into master Aug 7, 2019
@ffflorian ffflorian deleted the feat/bearer-auth branch August 7, 2019 11:58
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.

Add support for "Bearer Authentication" in operations
2 participants