Youtube API javascript upload video to predefined channel - javascript

I wanted to ask you if I could implement javascript youtube API in order to upload videos to a single predefined channel, without the need of authenticating.

Based from this thread, it might not be possible if you are trying to get the server to authorize on your behalf say if you were allowing people to upload videos to a single shared channel. You'd need to do some way of authorizing the client locally on the server which then has the server authorized to the YouTube account.
However, you may refer with this post which stated that if you don't want authentication for each upload process, you can use refresh token.

Related

How do I get a discord user's profile picture? [duplicate]

I am doing a website where you enter the user ID to get the discord pfp. The problem is i can't find any url or api with the user image. I am not trying to do a bot but a website. Can someone help me?
The Discord API documentation allows apps with the appropriate permissions to query user information (Get User API) which returns a User object containing an avatar field. The avatar field is a hash that can be used with the User Avatar CDN endpoint to retrieve the user's avatar.
It's worth noting that none of this can be done with Javascript in your website due to the Same Origin Policy which prevents client-side Javascript from making web requests to origins other than the one your website is loaded from. CORS could allow this, but it would be on Discord to allow your site to make requests.
Instead you would make some request to your site's backend and have it make the requests to Discord's APIs. You could keep using Javascript for this, via Node.js, but you also build your backend in just about any other language you like.
The 'displayAvatarURL()' method returns the url of the avatar of the user.
Use it like this:
let avatarUrl = user.displayAvatarURL()
More information about it: discord.js - displayAvatarURL()

Is a discord bot classified as a web server?

I am making a google classroom discord bot and i needed to fill out an OAuth form. to do this it asked me what I was making so I put a web server. and then it asked me for a URI. does this mean I have to own my own website? or is a discord bot not a webserver.
thanks in advance!
Any OAuth2 Forms will require a redirectURI which they will append the confirmation code, or send it to. While a Discord Bot in itself is Not a Web Server, you can create one using your VPS's external IP (If you have one, but you generally get one per VM.) by following a guide to do so.
https://www.oauth.com/oauth2-servers/redirect-uris/
Redirect URLs are a critical part of the OAuth flow. After a user successfully authorizes an application, the authorization server will redirect the user back to the application with either an authorization code or access token in the URL. Because the redirect URL will contain sensitive information, it is critical that the service doesn’t redirect the user to arbitrary locations.
NOTE: I don't think that changing your option from Web Server to whatever will change a thing, if you want to use redirectURI, which is required for OAuth2, then make a Web Server and connect it to your Bot.

YouTube API | Javascript- Upload video to a constant channel bypassing login.

I'm building a web application that allows a specific user to upload videos to a YouTube account through the use of the YouTube API. The uploading of videos will be done by only one person & videos will be uploaded only to one account. If the YouTube account is already authorized by the app to manage the channel etc, how can I setup the application in such a way that the user bypasses the authentication/login screen every time he/she needs to upload a video? (That is when the user exits and re-enters application.)
While reading, a solution I stumbled upon a solution which was to use a refresh token but I don't know how to integrate it with the code I have currently. The code I'm using is the one available on the Google Developers site, link below.
https://developers.google.com/youtube/v3/code_samples/javascript#upload-a-video
Please note that I've gone through & read all similar questions on this forum but none provides Javascript help/solution.
Normally i would say that you should use a service account which would allow you to preauthorize the access to YouTube. However the YouTube API does not support service accounts so your going to have to do it the hard way.
You will need to authenticate your application once and save the refresh token. Then you will be able to use the refresh token again later to get a new access token. You will have to watch this application refresh tokens can expire its rare but it can happen so you should have something set up that will allow you to quickly reauthenticate it and save a new refresh token.
To my knowledge it is not possible to get a refresh token with JavaScript your going to have to use a server sided language like node.js for example. This tutorial should show you how to get offline access with node js. Node.js Quickstart

youtube ask for channel selection while authenticating

I am using javascript sdk to authenticate google. In my webapp I am trying to upload video to youtube.
A youtube account might have multiple channels and I want to select the channel and send the information to the server with access token and all required value to upload a video.
I can authenticate a user from google but how can I display the youtube channel selection ui and also if there is no channel in the account I want to show error.
I have gone through youtube api but I found it very complex
Need help
YouTube is very different from other Google APIs. When your user authenticate your application they are not just authenticating you to YouTube you are actually getting authenticated to a single YouTube channel.
If you want to see the account selection you are going to have to force them to re authenticate you will then get a new access token associated to the channel that they pick.
prompt=consent should force them to re-authenticate but that depends on how you have implemented things.
Recap:
If a user has 5 channels you will to authenticate them once for each channel you will then have five access tokens each of which grants your application access to a single channel.

Service worker send push notifications even not on the website

I'm have a personal website and I think it will be perfect if I add the push notifications feature.
I'm new to service worker, but already know about push notification. I need the service worker that send push notification even the user isn't on my website.
How do I do that? I won't use a pay service like pushcrew. I want learn how to create it.
First of all. You'll need to host your website on a secure i.e. HTTPS domain. You could use GitHub Pages for the same. It is free and easy to use.
Then you could go over this documentation. It is pretty straightforward.
Here is an awesome demo/sample.
To give you a head-start, service workers are separate js files that are registered with the user's browser. After the user is registered and subscribed a URL is generated which can be used to invoke the user's browser(serviceworker.js) (These will be invoked even if your website is not open). So you are supposed to communicate that URL back to your servers for all the users and invoke all those URLs if you are sending a push-notification to everyone. Cheers!

Categories

Resources