--- title: Password Authenticator keywords: fastai sidebar: home_sidebar nb_path: "nbs/plugins.authenticators.password.ipynb" ---
{% raw %}
{% endraw %} {% raw %}
class MyAuthenticatedPlugin(PluginBase):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.logged_in = False
        self.authenticator = PasswordAuthenticator(self.client, self.pluginRun)
        
    def login(self, username, password):
        if not (username=="username" and password=="password"):
            raise ValueError("Wrong credentials.")
            
    def run(self):
        self.authenticator.authenticate(login_callback=self.login)
        self.logged_in = True
        print("done!")
    
    def add_to_schema(self):
        pass
{% endraw %} {% raw %}
pod_client = PodClient()

run = PluginRun("", "", "")
account = Account(service="myAccount")
run.add_edge("account", account)
run.status = "started"

pod_client.create(run)
pod_client.create(account)
pod_client.create_edge(run.get_edges("account")[0]);
{% endraw %}

Simulate entering credentials

{% raw %}

set_account_credentials[source]

set_account_credentials(pod_client, run_id, username, password)

{% endraw %} {% raw %}
{% endraw %} {% raw %}

simulate_enter_credentials[source]

simulate_enter_credentials(run_id:Param object at 0x7f13f2c8c910>=None, plugin:Param object at 0x7f13f2ba1040>=None, pod_full_address:Param object at 0x7f13f2ba1070>='http://localhost:3030', database_key:Param object at 0x7f13f2ba10a0>=None, owner_key:Param object at 0x7f13f2ba10d0>=None)

{% endraw %} {% raw %}
{% endraw %}