I have created a telegram app via https://my.telegram.org. After I did that I got data about api_id and api_hash but I can't find session name. Where can I find it?
When I use telethon function TelegramClient, I need to pass there SESSION:
from telethon import TelegramClient
client = TelegramClient(SESSION, API_ID, API_HASH)
I can't find the session name
Where can I find it?
You cant, you'll need to create it.
Telethon sessions are used to save the data of your current session.
They're not part of the Telegram API, just something Telethon introduced.
The first parameter you pass to the constructor of the TelegramClient is the session, and defaults to be the session name (or full path). That is, if you create a TelegramClient('anon') instance and connect, an anon.session file will be created in the working directory.
The file name of the session file to be used if a string is given (it may be a full path), or the Session instance to be used otherwise. If it’s None, the session will not be saved, and you should call log_out() when you’re done.
You can just pass None (to not save a session), or a 'usefull' name like Anon:
client = TelegramClient('anon', '19071234', 'e40ef8a46648716835434')
client.start()
Related
I've enabled RBAC as environment variable in docker-compose file.
- AIRFLOW__WEBSERVER__RBAC=True
I want to capture the user who kicked off a dag inside my dag files.
I tried using from flask_login import current_user. But, I get the value of current_user as None.
May I know how to capture user details using RBAC?
According to Airflow documentation as part of RBAC security model that is handled by Flask AppBuilder (FAB):
Airflow uses flask_login and exposes a set of hooks in the
airflow.default_login module. You can alter the content and make it
part of the PYTHONPATH and configure it as a backend in
airflow.cfg.
Flask-login module provides user management operations, thus you can fetch current user within a dedicated property flask_login.current_user, adding
some extra fields, as described in #3438 pull request:
if current_user and hasattr(current_user, 'user'):
user = current_user.user.username
elif current_user and hasattr(current_user, 'username'):
I suppose that you can use current_user.user.username to fetch a user login.
I'm using rga to get some data from Google Analytics. From the repo:
The principle of this package is to create an instance of the API Authentication, which is a S4/5-class (utilizing the setRefClass). This instance then contains all the functions needed to extract data, and all the data needed for the authentication and reauthentication. The class is in essence self sustaining.
The package creates and saves a local instance using:
rga.open(instance="ga", where="~/ga.rga")
When I try to knit, however, I get an error that the ga object (what would be the instance) is not found. The code works when I run the chunks in RStudio, however—I believe the error is related to this aspect:
[The command above] will check if the instance is already created, and if it is, it'll prepare the token. If the instance is not created [...] it will redirect the client to a browser for authentication with Google.
My guess is that knitr can't perform that last step and so, the object is never created.
How can I make this work? I'm thinking that there might be a way to load the local ga.rga file to bypass browser authentication.
You can bypass browser authentication by passing the client id and client secret key that you can get it from Google API console. Saving a local auth file in the dev env is always risky. You can try this code, this uses Google API and also saves the local instance -
rga.open(instance = "ga",
client.id = "<contains apps.googleusercontent.com>",
client.secret =<your secret key>, where ="~/ga.rga" )
Also ensure that desktop option setting is enabled in Google API console
I need to read the messages of some public channels in the application, as for example it happens https://tlgrm.ru/channels/tech As I understood, the bot for this business will not work. You need to use client api, but everywhere that with the channel methods are connected everywhere you need channel_id but where do I get it I do not know, I only have channel names, and how do I get it from it id I did not find such a method.
How can I get the channel's id by its name?
Assuming you're using python, I suggest Telethon library. You can use this piece of code to get channel_id and access_hash from #username:
from telethon.tl.functions.contacts import ResolveUsernameRequest
client = TelegramClient(session_file, api_id=X, api_hash='X')
client.connect()
response = client.invoke(ResolveUsernameRequest("username"))
print(response.channel_id)
print(response.access_hash)
Make sure you have already got your api_id and api_hash. And also make sure you have authenticated your app i.e. you have a working session_file. Just read Telethon's README in the Github page if you're not sure how to perform above steps.
In the latest version, you would do like this using the username of the channel
from telethon.tl.functions.contacts import ResolveUsernameRequest
response = client.invoke(ResolveUsernameRequest(<username>))
messages = client.get_message_history(response.peer,limit=1000)
import {Mongo} from 'meteor/mongo';
export const play = new Mongo.Collection('play');
Meteor.methods({
'play.insert':(value)=>{
let doc_id = play.insert({value});
console.log(doc_id);
}
});
When this method is called, both client side and server side have the same doc_id.
How does this possible? How does the server know what _id the client is used?
Because when play.insert({value}) is invoked in the server, {value} have no _id, how does the server "knows" which id to use?
According to the official Meteor guide
Each Meteor Method invocation shares a random generator seed with the client that called the Method, so any IDs generated by the client and server Methods are guaranteed to be the same. This means you can safely use the IDs generated on the client to do things while the Method is being sent to the server, and be confident that the IDs will be the same when the Method finishes. One case where this is particularly useful is if you want to create a new document in the database, then immediately redirect to a URL that contains that new document’s ID.
If you would like to learn more about it, you can check this section of Meteor guide.
We need to configure the IdentityProvider from metadata stored in a database. It would seem though that the only way to specify the metadata to IdentityProvider is through metadataLocation property which supports a URL or file path.
Is there anyway, which I've missed, to pass a stream object that holds the metadata to the IdentityProvider?
Thanks
I'm not aware of any way using the standard code. The Load method that takes a stream is marked as internal, see here:
https://github.com/KentorIT/authservices/blob/master/Kentor.AuthServices/Metadata/MetadataLoader.cs
You could:
Write your database value to a temporary location and give this file path to load
Write an api route that serves up the metadata for a given Idp as a url
Make an open source contribution to add support for this
Don't use MetadataLocation but instead construct the IdentityProvider object and separately set signing key, entity id, binding etc.
etc.