Skip to content

Commit

Permalink
feat: rename rename OAuthOnAuthorizeToken to OAuthTokenInput; fix flo…
Browse files Browse the repository at this point in the history
…w warnings
  • Loading branch information
Vladimir Berezovsky committed Jul 15, 2020
1 parent a98f43a commit efcfe27
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
11 changes: 6 additions & 5 deletions src/endpoints/OAuth.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { BaseError } from "../errors";
import type {
OAuthAuthorizeInput,
OAuthOnAuthorizeToken,
OAuthTokenInput,
TokenResponseData
} from "../types";
import Endpoint from "../endpoints/Endpoint";
Expand All @@ -11,19 +11,20 @@ import Client from "../Client";
export default class OAuth extends Endpoint {
name = "oauth";

getToken(input: OAuthOnAuthorizeToken) {
getToken(input: OAuthTokenInput) {
const clientId = input.clientId || this.options.clientId;
const clientSecret = input.clientSecret || this.options.clientSecret;
let redirectUri = input.redirectUri || this.options.redirectUri;
const { authorizationCode } = input;

const body = new URLSearchParams();

// $FlowFixMe
if (!clientId || !clientSecret || !redirectUri) {
throw new Error("OAuthTokenInput required");
}

body.append("client_id", clientId);
// $FlowFixMe
body.append("client_secret", clientSecret);
// $FlowFixMe
body.append("redirect_uri", redirectUri);

body.append("code", authorizationCode);
Expand Down
5 changes: 2 additions & 3 deletions src/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ export type CommandOptions = {
analyticsCallback: AnalyticsCallback,
apiUrl: string | Promise<string>,
clientId?: string,
clientSecret?: string | Promise<string>,
clientSecret?: string,
objectUrl: string | Promise<string>,
previewUrl: string | Promise<string>,
shareId?: () => Promise<string | ShareDescriptor | ShareUrlDescriptor | void>,
Expand Down Expand Up @@ -462,7 +462,6 @@ export type Membership = {
};

export type Organization = {
features: { [feature: string]: boolean },
hasBillingInfo?: boolean,
id: string,
isUsernameOrganization?: boolean,
Expand Down Expand Up @@ -1682,7 +1681,7 @@ export type OAuthAuthorizeInput = {
state: string
};

export type OAuthOnAuthorizeToken = {
export type OAuthTokenInput = {
redirectUri: string,
clientSecret: string,
clientId: string,
Expand Down

0 comments on commit efcfe27

Please sign in to comment.