Auth0 Home Blog Docs

typescript definition updated and wrong ?

social-connections
auth0js
login
authorization
custom-ui

#1

I’m using custom UI and to login via a social provider I used to use the code below

this.auth0.authorize({
  connection: 'google-oauth2',
  state: "SOME_STATE_STRING"
});

However now when compiling, typescript is throwing errors. The interface for AuthorizeOptions is now like so:

authorize(options: AuthorizeOptions): void;
interface AuthorizeOptions {
    domain?: string;
    clientID?: string;
    redirectUri: string;
    responseType: string;
    responseMode?: string;
    state?: string;
    nonce?: string;
    scope?: string;
    audience?: string;
}

Seems like that was added 9 days ago. So I don’t know if it’s an error but it would be nice to have the doc inline with the typescript definition. https://github.com/DefinitelyTyped/DefinitelyTyped/commit/524b072a5afa4ae9583a515dd5d44ce1d050ed5c
So how we tell auth0 we want to authorize via google ? are the @types/ out of date ?


#2

What version of Auth0.js are you using? You are passing statewithout a value. If you don’t need a state value, you can try:

this.auth0.authorize({
   connection: 'google-oauth2'
 });

Otherwise pass in a valid state parameter:

this.auth0.authorize({
   connection: 'google-oauth2',
   state: "SOME_STATE_STRING"
 });

#3

There is a snippet in my question explaining why this won’t compile in typescript. I believe the type definitions are outdated. For the version I’m using ^8.6. For the state variable it’s defined above, sorry for not being clear. I now edited my question so it’s clearer…


#4

Can you clarify the specific error that is thrown? It seems like the PR you referenced failed to include the connection parameter in the AuthorizeOptions. I suggest raising an issue in that repo, or submitting a PR for the required change.


#5