Skip to content

Conversation

@ncronquist
Copy link

  • The TokenResponse type was unioning to different types and so only
    the shared keys, oauth_callback_confirmed, were actually available as
    keys on that type
  • This change switches TokenResponse back to an interface and uses
    optional properties for keys that may not be present

Notes

  • This fix resolved a typing error for me where the following wouldn't work:
// Property 'oauth_token' does not exist on type 'TokenResponse'.ts(2339)
const { oauth_token } = await client.getRequestToken("http://localhost:4000/auth/callback/twitter")
  • That said, I'm new to typescript so I apologize if there is a more standard way to handle this

- The TokenResponse type was unioning to different types and so only
  the shared keys, oauth_callback_confirmed, were actually available as
  keys on that type
- This change switches TokenResponse back to an interface and uses
  optional properties for keys that may not be present
@ciffelia
Copy link
Collaborator

Try this:

const oauthResult = await client.getRequestToken(callbackUrl)

if (oauthResult.oauth_callback_confirmed === 'true') {
  // in this scope you can access oauth_token and oauth_token_secret
  console.log(oauthResult.oauth_token)
} else {
  // in this scope oauth_token and oauth_token_secret are not available
  throw new Error('oauth_callback_confirmed is not "true".')
}

@ciffelia ciffelia closed this Aug 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants