diff --git a/src/endpoints/OAuth.js b/src/endpoints/OAuth.js index 9ffcc9b1..7eda13d9 100644 --- a/src/endpoints/OAuth.js +++ b/src/endpoints/OAuth.js @@ -2,7 +2,7 @@ import { BaseError } from "../errors"; import type { OAuthAuthorizeInput, - OAuthOnAuthorizeToken, + OAuthTokenInput, TokenResponseData } from "../types"; import Endpoint from "../endpoints/Endpoint"; @@ -11,7 +11,7 @@ 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; @@ -19,11 +19,12 @@ export default class OAuth extends Endpoint { 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); diff --git a/src/types.js b/src/types.js index f5df3cf5..3836bc4e 100644 --- a/src/types.js +++ b/src/types.js @@ -160,7 +160,7 @@ export type CommandOptions = { analyticsCallback: AnalyticsCallback, apiUrl: string | Promise, clientId?: string, - clientSecret?: string | Promise, + clientSecret?: string, objectUrl: string | Promise, previewUrl: string | Promise, shareId?: () => Promise, @@ -462,7 +462,6 @@ export type Membership = { }; export type Organization = { - features: { [feature: string]: boolean }, hasBillingInfo?: boolean, id: string, isUsernameOrganization?: boolean, @@ -1682,7 +1681,7 @@ export type OAuthAuthorizeInput = { state: string }; -export type OAuthOnAuthorizeToken = { +export type OAuthTokenInput = { redirectUri: string, clientSecret: string, clientId: string,