How to generate access token for youtube api? - javascript

I am trying to integrate Youtube API into my project but to start working with it, I need to generate the access token. I searched the internet and found multiple articles that confused me a lot. I have seen various methods to generate it, but none of them works for me.
I also tried this npm library, but this gives me the following error:
code: 403,
errors: [
{
message: 'The request is not properly authorized.',
domain: 'youtube.activity',
reason: 'forbidden'
}
]
I am tired of searching more on this, so if anyone has any idea to get it, Please tell me. It will be a great help.

Did you try to follow the official documentation? There are clear steps on how to get access.
https://developers.google.com/youtube/v3/getting-started#before-you-start

Related

discord.js error 50001: Missing Access while creating slash commands

I've been trying to make slash commands in discord.js for a discord bot (a personal project to practice coding) and I've been getting this error, with no success in trying to solve it... I've already given OAuth2 access to the command creation, so I have no idea what I'm doing wrong.
https://pastebin.com/y5g2P8Cm
DiscordAPIError[50001]: Missing Access
at SequentialHandler.runRequest (C:\Users\Nicolò\Desktop\colino-bot\node_modules\#discordjs\rest\dist\lib\handlers\SequentialHandler.js:198:23)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async SequentialHandler.queueRequest (C:\Users\Nicolò\Desktop\colino-bot\node_modules\#discordjs\rest\dist\lib\handlers\SequentialHandler.js:99:20) {
rawError: { message: 'Missing Access', code: 50001 },
code: 50001,
status: 403,
method: 'put',
url: 'https://discord.com/api/v9/applications/914567485158744104/guilds/251345856169508864/commands'
}
EDIT: Solved, apparently I just removed some permissions and now it works... I have no clue why it works this way, but ok.
When your bot is added to a server via an OAuth2 link it requires the application.commands to be able to register slash commands.
Even if you update the scopes in your link the bot has to be removed and then re-added back to the server with the new link for the changes to take effect.
Learn more about discord OAauth2 scopes here
EDIT: Solved, apparently I just removed some permissions and now it works... I have no clue why it works this way, but ok.
Anyone encountering this problem the solution is pretty simple.
It DOES NOT depend on the permissions that have been provided to the bot when creating the OAuth2 link to invite the bot. It is not enough to just select the bot option, the applications.commands option also needs to be selected, see captured screenshot in the following link

Trying to build a slack bot and facing error "Error: not_allowed_token_type"

Was just trying to build a simple slack bot by following a YouTube link and started getting the error
Error: not_allowed_token_type
const bot = new SlackBot({
token: 'xoxb-TOKEN_GENERATED FROM SLACK SITE',
name: 'escalatorbot' // what name should I give here
})
Can somebody tell why I am facing this error
From your code snippet, I think you're using Slackbots.js and encountering a known problem resulting from recent changes in the slack api. The issue is logged here: https://github.com/mishk0/slack-bot-api/issues/145
The issue is releated with the new granular permissions app in slack, use the legacy bot on this url: https://api.slack.com/apps?new_classic_app=1 and then in Bots you can add legacy bot user and generate correct token
I have not fully understood your use case. On which API you got this error? For now, I can suggest you to use slack built-in tool for testing all API's (https://api.slack.com/methods/api.test/test)

chrome.identity.getAuthToken returning "bad client id: {0}" error

I'm trying to use chrome.identity.getAuthToken to get a token, but every time I try this error shows up:
OAuth2 request failed: Service responded with error: 'bad client id: {0}'
I have no idea why this is happening. The client ID I put in manifest.json is exactly the same as the one on the Google Developers Console, and the correct scopes is also included:
oauth2: {
"client_id": "NUMBERS-NUMBERS&LETTERS.apps.googleusercontent.com",
"scopes": ["https://www.googleapis.com/auth/SOME_SERVICE"]
}
The extension is up on the webstore, and I don't see why it is still giving the bad client ID error.
What is possibly causing this error? What am I missing here?
Just as a note for myself and for someone run into.
I have encounter this problems with chrome app , the answers is not my problem ,and finally I found the solution for my problem but produce the same error as the question.
As https://developer.chrome.com/apps/app_identity#client_id say is much special for chrome apps, you have to create a separate client id for your chrome app.
Go to the "API Access" navigation menu item and click on the Create an OAuth 2.0 client ID... blue button.
Enter the requested branding information, select the Installed application type.
you must to choose Installed application an set you Application ID.
what's your Application ID ?
chrome-extension://your application id
chrome-extension://gfmehiepojbflifceoplblionpfclfhf/
I overcomed this problem by setting up the email address and product name in "Consent screen" in the Google Developer Console.
Please refer to https://developers.google.com/console/help/new/#userconsent for detail.
I had a similar problem. Everything seemed to work fine on my own laptop, but when i ran it on another device i got that "bad client id" error.
My problem was that the client-id changed from one device to another, as i did not yet upload my extension to the chrome store.
To overcome that problem, i followed the instructions of How to change chrome packaged app id Or Why do we need key field in the manifest.json?.
You need to create a key to keep the client-id persistent through all devices.
Hope that helps finding the right answer for people with the same issue quicker.

Error with Deezer Javascript API: Valid token required?

My Deezer-app used to work fine with the Javascript API, but stopped working recently.
I get the following error:
{"error": "VALID_TOKEN_REQUIRED":true},"results":{}}
I can't find any information about this error and I have no idea how to debug it.
The url is www.rapucationals.com
Update: Please check out the code (www.rapucationals.com).
This is the call that fails: http://www.deezer.com/ajax/gw-light.php?api_version=1.0&api_token=a7cadc94893e55c9fd79da702354c86b&method=song.getListData&input=3&cid=0053621bf26d2cf98

Facebook access token issue in JS implementation

I am new to FB apps and trying to get the accessToken for my website using JS. I have followed the steps given on the API docs, but I keep getting an
"error": {
"type": "OAuthException",
"message": "Error validating application."
}
I know that theres some issue with my implementation. Can someone please help me out.
If you can provide a link to a tutorial/code snippet that would be really great.
Since today there is a change in Facebook Graph API, the given access token is now URI-encoded, it may be this your problem, give a look here: http://forum.developers.facebook.net/viewtopic.php?pid=273730

Categories