Passing scopes as array to authorizeURL function produces a url with invalid_scope error
opchaves opened this issue · comments
The typescript definition for the scope
prop on version 2.1.2 says it can be OauthScope | OauthScope[]
. When I try passing an array of scopes it the request fails with an invalid_scope
error and this is due to an invalid url that is being generated.
const authLink = WebflowClient.authorizeURL({
state: webflow.state,
// @ts-ignore
scope: [OauthScope.SitesRead, OauthScope.SitesWrite, OauthScope.AuthorizedUserRead],
redirectUri: webflow.redirectUri,
clientId: webflow.clientId,
});
// Error response
/webflow/auth?error=invalid_scope&error_description=The%20following%20scopes%20are%20invalid%3A%20sites%3Aread%2Bsites%3Awrite%2Bauthorized_user%3Aread&state=<some-state>
To make it work I'm using @ts-ignore
and interpolation to pass all scopes I need.
const authLink = WebflowClient.authorizeURL({
state: webflow.state,
// @ts-ignore
scope: `${OauthScope.SitesRead} ${OauthScope.SitesWrite} ${OauthScope.AuthorizedUserRead}`,
redirectUri: webflow.redirectUri,
clientId: webflow.clientId,
});
Additionally the OauthScope
type doesn't include all the scope types listed here.
@opchaves @tomelliot this is fixed in v2.2.1
, please reopen if you still have issues!