twitter 获取access token出错时, 打印更详细的日志
This commit is contained in:
parent
3691d000da
commit
b8b8ec4dfc
@ -1,5 +1,6 @@
|
|||||||
const consumerKey = process.env.TWITTER_CLIENT_ID
|
const consumerKey = process.env.TWITTER_CLIENT_ID
|
||||||
const consumerSecret = process.env.TWITTER_CLIENT_SECRET
|
const consumerSecret = process.env.TWITTER_CLIENT_SECRET
|
||||||
|
import logger from 'logger/logger'
|
||||||
import { OAuth } from 'oauth'
|
import { OAuth } from 'oauth'
|
||||||
import { promisify } from 'util'
|
import { promisify } from 'util'
|
||||||
|
|
||||||
@ -87,9 +88,12 @@ export async function getOAuthAccessTokenWith({
|
|||||||
oauthRequestTokenSecret,
|
oauthRequestTokenSecret,
|
||||||
oauthVerifier,
|
oauthVerifier,
|
||||||
function (error, oauthAccessToken, oauthAccessTokenSecret, results) {
|
function (error, oauthAccessToken, oauthAccessTokenSecret, results) {
|
||||||
return error
|
if (error) {
|
||||||
? reject(new Error('Error getting OAuth access token'))
|
logger.error(error)
|
||||||
: resolve({ oauthAccessToken, oauthAccessTokenSecret, results })
|
reject(new Error('Error getting OAuth access token'))
|
||||||
|
} else {
|
||||||
|
resolve({ oauthAccessToken, oauthAccessTokenSecret, results })
|
||||||
|
}
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
@ -97,9 +101,12 @@ export async function getOAuthAccessTokenWith({
|
|||||||
export async function getOAuthRequestToken() {
|
export async function getOAuthRequestToken() {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
oauthConsumer.getOAuthRequestToken(function (error, oauthRequestToken, oauthRequestTokenSecret, results) {
|
oauthConsumer.getOAuthRequestToken(function (error, oauthRequestToken, oauthRequestTokenSecret, results) {
|
||||||
return error
|
if (error) {
|
||||||
? reject(new Error('Error getting OAuth request token'))
|
logger.error(error)
|
||||||
: resolve({ oauthRequestToken, oauthRequestTokenSecret, results })
|
reject(new Error('Error getting OAuth request token'))
|
||||||
|
} else {
|
||||||
|
resolve({ oauthRequestToken, oauthRequestTokenSecret, results })
|
||||||
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user