-
-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Typescript definition is broken (at least for cjs) #21
Comments
@orgads this is not a documented use case, you shouldn't rely on calling the default function directly. Instead, call one of the methods demonstrated in the README. There are methods for client credentials, authorization code, owner credentials, and refresh token grants. If there's another you need, I'm happy to add it or better yet submit a PR. |
It's the same: import axios from 'axios'
import oauth from 'axios-oauth-client'
const getAuthorizationCode = oauth.authorizationCode(
axios.create(),
'https://oauth.com/2.0/token', // OAuth 2.0 token endpoint
'CLIENT_ID',
'CLIENT_SECRET',
'https://your-app.com/oauth-redirect' // Redirect URL for your app
)
getAuthorizationCode('AUTHORIZATION_CODE');
|
Same with 2.0.1. Please reopen. |
@orgads can you provide a complete code example that I can run that reproduces your issue? Preferably, a repository that demonstrates the problem. If so I'll be glad to reopen this and fix whatever the problem is. I need more than the code snippet above to be able to see what's going on. |
I already did. Try this: import axios from 'axios'
import oauth from 'axios-oauth-client'
const getAuthorizationCode = oauth.authorizationCode(
axios.create(),
'https://oauth.com/2.0/token', // OAuth 2.0 token endpoint
'CLIENT_ID',
'CLIENT_SECRET',
'https://your-app.com/oauth-redirect' // Redirect URL for your app
)
getAuthorizationCode(); |
Or do you also need package.json and tsconfig.json? |
@orgads Yes, I need those too. |
package.json: {
"name": "jstest",
"version": "1.0.0",
"description": "",
"main": "index.js",
"keywords": [],
"author": "",
"type": "commonjs",
"license": "ISC",
"dependencies": {
"@tsconfig/node18": "^1.0.1",
"@types/node": "^18.11.11",
"axios": "^1.2.1",
"axios-oauth-client": "^2.0.1",
"typescript": "^4.9.4"
}
} tsconfig.json: {
"compilerOptions": {
"target": "es2022",
"module": "commonjs",
"skipLibCheck": true
}
} |
Notice that if |
Got it thanks. What command are you running that reproduces the problem? |
npx tsc
node test.js |
@orgads thanks a lot! Try it now in v2.0.2 |
@orgads also you will need to change |
This also breaks my project. Is there a way to create definitions that are compatible with plain cjs? |
Could you elaborate on why you are unable to use |
This seems to be at the root of the problem: https://www.typescriptlang.org/docs/handbook/2/modules.html#commonjs-and-es-modules-interop Unless someone can show me a build setting that makes this work, I'm going to just say that if you're using typescript you either need to set Again, if you or anyone else can show me how to adjust my Typescript build settings to make this work with your settings, I'm open to making further changes. |
The text was updated successfully, but these errors were encountered: