Pytube login with non CLI program - pytube

I want to make a non CLI pytube code, but some videos require signing in and I have to use CLI to bypass it. I couldn't find anything in the documentation.

Related

How to fake authentication when testing firebase functions online?

I'm trying to write tests for my Firebase Cloud Functions, specifically the HTTPS ones. The app uses a permissions system in which each signed-up user of the app has their own entry in Firestore storing the list of permissions they have, indexed by their uid. When these functions are called from the client, the function checks context.auth to determine if the user is authenticated, then uses context.auth.uid to find the entry for the user in Firestore and determine if they have permissions to run this function.
I am now trying to write tests for these functions using the online mode, as recommended in Google's documentation. However, there does not seem to be a way (at least in this mode) to control the context.auth.uid or mock it for the test. As a result, it seems like it might be impossible to tests these functions in this mode.
Is there any way to do this I'm missing, or some workaround?
You may use the signInAnonymously method this can create and use temporary anonymous accounts to authenticate with Firebase anonymously. According to Firebase Test SDK online mode means that other Google SDKs used in your function will work as well. Install both firebase-functions-test and Mocha, a testing framework, by running the following commands in your functions folder:
npm install --save-dev firebase-functions-test
npm install --save-dev mocha
Make sure to follow test setup and used the Authenticate with Firebase Anonymously.

Firebase Functions Config: hide Secret in CLI itself

I need to set a secret in my functions config but I want to make sure, that this secret cannot be accessed by anyone, even if the person has access to the firebase project and thus the cli itself.
What I mean by that is, if I set the secret in my cli, I can then retrieve this secret firebase functions:config:get. There are people who might have access to the firebase cli of this project that should not be able to access this secret.
Is there a way to achieve this?
The functions configuration you're referring to is only saved on the local machine. It will not be checked into source control. Other developers who use the CLI in the same project, but on different machines, will not be able to see that configuration.
The configuration will be available in the deployed code, however. If each developer needs a fully isolated configuration at runtime, they should each have their own project to work with.

Firebase CLI - How to Manage Cloud Functions

Using the firebase-cli you can easily deploy functions and show the logs. But I have yet to find the option to download or retrieve cloud functions.
I've dug through quiet a bit of the -h commands and nothing yet.
Is it possible to download / retrieve a projects cloud functions through the firebase-cli? I tend to switch between computers from home to work and I need to go to the console to copy the source code and redeploy.
The Firebase CLI doesn't provide a way to get deployed code. It's expected that you use some form of source control for managing code between developers and machines.

Deploy via firebase-tools API without previous login

I'm currently building an open-source microservice that makes use of Firebase Database, Hosting & Functions. The plan is to pack everything in a single binary and distribute this. So users will have a hazzle-free, "bring your own Firebase project"-solution. They'll just have to download the binary and their Firebase secret key and can then create a user and deploy the service via CLI.
The problem is, that firebase-tools require a $FIREBASE_TOKEN when deploying via its API. So users would have to install firebase-tools in order to be able to generate that token and they would also have to store it (or re-generate it frequently).
Since I would like to provide a hazzle-free experience, I'd rather generate that token myself with the help of the secret key.
The question is: is this even possible? And if yes: how??
My workaround for this is to reflect the login- and logout-commands of the Firebase-CLI on my own binary's CLI. So the user won't have to install another tool.
To get the refresh_token I then read the data from the firebase-tools-configstore, that is located in the user folder. This feels a little dirty, like accessing a private API. But I couldn't come up with a better solution. And it works.

Firebase - Collaborate Hosting Development

A guys shared a project with me. Using my online / cloud based IDE, I created a new HTML5 project.
$ npm install -g firebase-tools
$ firebase login
$ firebase list
$ firebase use <shared-project>
$ firebase init
How do I get all the existing hosted files into my IDE so that I can collaborate on this project?
There is no way to download the files from Firebase Hosting within the console. Firebase Hosting is in that sense no replacement for a proper version control system. The best way would be to set up such a version control system for sharing the code with the other developer.
If that's not an option, you an try crawling the site. See this answer: Firebase code pull
I may be coming a bit late but just to add to what Frank said:
If the person you are collaborating with uses somekind of packaging solution like webpack, you won't be able to download the project's source files, since only the bundles will be publicly available.
My guess is that the only way to get the necessary files to collaborate on the project, is trough a proper versioning system, since even if you receive the whole project in a zip, you'd have no way of keeping it in sync with the rest of the team.

Resources