TimLuo465 / baidu-translate-api

A free and unlimited API for Baidu Translate
MIT License
71 stars 17 forks source link

Error 401 Unauthorized #17

Open Error404-RedRose opened 4 years ago

Error404-RedRose commented 4 years ago

I made a discord bot translator with your API and its works fine client side server, But when I uploaded the bot to Heroku I get the error listed in the title. I did give HEROKU_API_KEY a proper key but I think I may need a key for Your API to access the site on Heroku server side client. But I'm not certain where the Unauthorized is happening, any help?

TimLuo465 commented 4 years ago

In my mind, the API has not access key. Is there any error message screen shot or more useful info?

Error404-RedRose commented 4 years ago

2020-09-16T18:07:53.983401+00:00 app[worker.1]: { statusCode: 401, statusMessage: 'Unauthorized' }

Error404-RedRose commented 4 years ago

thats all

Error404-RedRose commented 4 years ago

This is a global issue with any bot running this server side

Error404-RedRose commented 4 years ago

but likely something simple to fix with a access key

Error404-RedRose commented 4 years ago

Im currently trying to find more about heroku's oath

Error404-RedRose commented 4 years ago

What is the name for the token oath? example BAIDU_TOKEN=123351232534545323424

???

I got a oath token from Heroku now I just need the Token name to put it in the heroku config vars

TimLuo465 commented 4 years ago

It may be this token. The token store in a config file in your local env. It should be store failed in heroku.

Error404-RedRose commented 4 years ago

FANYI_BAIDU_URL ?

Error404-RedRose commented 4 years ago

or just the word: token ?

TimLuo465 commented 4 years ago

image

Error404-RedRose commented 4 years ago

is that a static token?

Error404-RedRose commented 4 years ago

can you ask the developer to make a token save file please... I really need to get this to work asap for a server

Error404-RedRose commented 4 years ago

I tried to make a function that writes a json token + value and although its coded good the token isnt being updated at all even when I call though the script. So again can you please ask developer to make a token save file?

TimLuo465 commented 4 years ago

I add a globalConfig at the lastest version. you can set useLocalStore: true. The token config will store in local memory not the config file.

const translate = require("baidu-translate-api");

translate.setGlobalConfig({ useLocalStore: true });
// TODO translate ....
Error404-RedRose commented 4 years ago

thanks allot

Error404-RedRose commented 4 years ago

the storing doesn't update for me. I tried executing: translate.setGlobalConfig({ useLocalStore: true }); and used the full translator. to see if it would update.

image

Error404-RedRose commented 4 years ago

I think its because when I execute translate.setGlobalConfig({ useLocalStore: true }); it doesn't change the globalConfig.js

Error404-RedRose commented 4 years ago

but I even set the globalConfig.js to true manually and it didn't do anything. I don't see why it doesn't work your code seems good.

TimLuo465 commented 4 years ago

I'm sorry for that. I fixed at lastest version.

Error404-RedRose commented 4 years ago

neither the token or useLocalStore updated still after using the function. I reinstalled all my modules it has no vulnerabilities.

Error404-RedRose commented 4 years ago

it may have not been pushed to npm yet

TimLuo465 commented 4 years ago

I have pushed to npm at that time. The lastest version is 0.4.3. pls make it sure.

Error404-RedRose commented 4 years ago

I updated but your new update doesnt have modules in baidu-translate-api folder

Error404-RedRose commented 4 years ago

so it doesn't run

Danyzzz commented 3 years ago

Is there any news on solving this problem? I'm interested too.

thanks!

Spaskich commented 3 years ago

I'm facing the same issue as well. I tried waiting for half an hour after getting the "Unauthorized" error to see if it's because of exceeding some limits, but it doesn't work. Setting the translate.setGlobalConfig({ useLocalStore: true }); doesn't seem to change anything.

Error404-RedRose commented 3 years ago

For now until we get an update on this matter run your app client side so the TOKEN is valid by your PC client updates

Spaskich commented 3 years ago

Hey, has anyone found a solution to this problem? As far as I can see, the problem revolves around the generation of a new token. @TimLuo465 is there a way I can trigger the token.js script manually? Or can you help me understand the way it works because I can't seem to open the url you've provided in the script?