René's URL Explorer Experiment


Title: Register a new secret agent · python-sdbus/python-sdbus-networkmanager · Discussion #73 · GitHub

Open Graph Title: Register a new secret agent · python-sdbus/python-sdbus-networkmanager · Discussion #73

X Title: Register a new secret agent · python-sdbus/python-sdbus-networkmanager · Discussion #73

Description: Register a new secret agent

Open Graph Description: Hi, I want to create a small python script that does the same thing as 'nmcli -t agent secret', i.e. register itself as the NetworkManager's secret agent and forward all password requests to the te...

X Description: Hi, I want to create a small python script that does the same thing as 'nmcli -t agent secret', i.e. register itself as the NetworkManager's secret agent and forward all password reques...

Opengraph URL: https://github.com/python-sdbus/python-sdbus-networkmanager/discussions/73

X: @github

direct link

Domain: patch-diff.githubusercontent.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"QAPage","mainEntity":{"@type":"Question","name":"Register a new secret agent","text":"

Hi,
\nI want to create a small python script that does the same thing as 'nmcli -t agent secret', i.e. register itself as the NetworkManager's secret agent and forward all password requests to the terminal input, replacing the systems dialog. I'm new to D-Bus and couldn't figure out how to do that using python-sdbus-networkmanager. Would it be possible to add a small example for that?

","upvoteCount":1,"answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"

After reading NetworkManager documentation I realized that the agent is not required to obtain any D-Bus names.

\n

So I fixed your code and added example of overriding the agent methods:

\n
from __future__ import annotations\n\nfrom asyncio import new_event_loop\nfrom typing import Any\n\nimport sdbus\nfrom sdbus_async.networkmanager import (\n    NetworkManagerSecretAgentInterfaceAsync,\n    NetworkManagerAgentManager,\n    NetworkManagerConnectionProperties,\n)\n\nsdbus.set_default_bus(sdbus.sd_bus_open_system())\n\n\nclass MySecretAgent(NetworkManagerSecretAgentInterfaceAsync):\n    @sdbus.dbus_method_async_override()\n    async def get_secrets(\n        self,\n        connection: NetworkManagerConnectionProperties,\n        connection_path: str,\n        setting_name: str,\n        hints: list[str],\n        flags: int,\n    ) -> dict[str, dict[str, tuple[str, Any]]]:\n        \"\"\"Retrieve stored secrets\"\"\"\n        print(\"get_secrets called\")\n        print(\"Connection:\", connection)\n        print(\"Connection path:\", connection_path)\n        print(\"Setting name:\", setting_name)\n        print(\"Hints:\", hints)\n        print(\"Flags:\", flags)\n        raise NotImplementedError\n\n    @sdbus.dbus_method_async_override()\n    async def save_secrets(\n        self,\n        connection: NetworkManagerConnectionProperties,\n        connection_path: str,\n    ) -> None:\n        \"\"\"Save given secrets\"\"\"\n        print(\"save_secrets called\")\n        print(\"Connection:\", connection)\n        print(\"Connection path:\", connection_path)\n        raise NotImplementedError\n\n\nsecret_agent = MySecretAgent()\n\n\nasync def start() -> None:\n    # Start serving at /org/freedesktop/NetworkManager/SecretAgent path\n    secret_agent.export_to_dbus('/org/freedesktop/NetworkManager/SecretAgent')\n    # Register the agent\n    agent_manager = NetworkManagerAgentManager()\n    await agent_manager.register('org.example.test')\n    print(\"Registered\")\n\n\nloop = new_event_loop()\nloop.run_until_complete(start())\nloop.run_forever()
\n

After running it and editing some Wifi passwords with nm-connection-editor it seems to be working:

\n
Registered\nsave_secrets called\nConnection: {'connection': {'id': ('s', 'Access Point'), .....................\nConnection path: /org/freedesktop/NetworkManager/Settings/8\n
","upvoteCount":0,"url":"https://github.com/python-sdbus/python-sdbus-networkmanager/discussions/73#discussioncomment-13122191"}}}

route-pattern/_view_fragments/Voltron::DiscussionsFragmentsController/show/:user_id/:repository/:discussion_number/discussion_layout(.:format)
route-controllervoltron_discussions_fragments
route-actiondiscussion_layout
fetch-noncev2:8a75dd72-79e1-916c-1935-d9fffe06980e
current-catalog-service-hash9f0abe34da433c9b6db74bffa2466494a717b579a96b30a5d252e5090baea7be
request-idD152:EB967:11A0298:1679B8A:698FF039
html-safe-nonce2d951fbbe8be3b51f39090340246cd7c4612b0b97711ac91ab749d8f44cefe77
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMTUyOkVCOTY3OjExQTAyOTg6MTY3OUI4QTo2OThGRjAzOSIsInZpc2l0b3JfaWQiOiIxMTMyMjQwNjI3NzIxNzkwMDEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmacc727e604cb21a4803ee83afb26ebfe5f861d1301a39fd6db87073e39ea601452
hovercard-subject-tagdiscussion:8284371
github-keyboard-shortcutsrepository,network-graph,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/discussions_fragments/discussion_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/Voltron::DiscussionsFragmentsController/show/python-sdbus/python-sdbus-networkmanager/73/discussion_layout
twitter:imagehttps://opengraph.githubassets.com/ca38e48147f333ee7e00e5d6497be31776a8224873f83a60ed89a9f4d37f9df2/python-sdbus/python-sdbus-networkmanager/discussions/73
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/ca38e48147f333ee7e00e5d6497be31776a8224873f83a60ed89a9f4d37f9df2/python-sdbus/python-sdbus-networkmanager/discussions/73
og:image:altHi, I want to create a small python script that does the same thing as 'nmcli -t agent secret', i.e. register itself as the NetworkManager's secret agent and forward all password requests to the te...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None42c603b9d642c4a9065a51770f75e5e27132fef0e858607f5c9cb7e422831a7b
turbo-cache-controlno-preview
go-importgithub.com/python-sdbus/python-sdbus-networkmanager git https://github.com/python-sdbus/python-sdbus-networkmanager.git
octolytics-dimension-user_id88226657
octolytics-dimension-user_loginpython-sdbus
octolytics-dimension-repository_id384529652
octolytics-dimension-repository_nwopython-sdbus/python-sdbus-networkmanager
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id384529652
octolytics-dimension-repository_network_root_nwopython-sdbus/python-sdbus-networkmanager
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release3b33c5aedc9808f45bc5fcf0b1e4404cf749dac7
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://patch-diff.githubusercontent.com/python-sdbus/python-sdbus-networkmanager/discussions/73#start-of-content
https://patch-diff.githubusercontent.com/
Sign in https://patch-diff.githubusercontent.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython-sdbus%2Fpython-sdbus-networkmanager%2Fdiscussions%2F73
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://patch-diff.githubusercontent.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython-sdbus%2Fpython-sdbus-networkmanager%2Fdiscussions%2F73
Sign up https://patch-diff.githubusercontent.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fdiscussions_fragments%2Fdiscussion_layout&source=header-repo&source_repo=python-sdbus%2Fpython-sdbus-networkmanager
Reloadhttps://patch-diff.githubusercontent.com/python-sdbus/python-sdbus-networkmanager/discussions/73
Reloadhttps://patch-diff.githubusercontent.com/python-sdbus/python-sdbus-networkmanager/discussions/73
Reloadhttps://patch-diff.githubusercontent.com/python-sdbus/python-sdbus-networkmanager/discussions/73
python-sdbus https://patch-diff.githubusercontent.com/python-sdbus
python-sdbus-networkmanagerhttps://patch-diff.githubusercontent.com/python-sdbus/python-sdbus-networkmanager
Notifications https://patch-diff.githubusercontent.com/login?return_to=%2Fpython-sdbus%2Fpython-sdbus-networkmanager
Fork 11 https://patch-diff.githubusercontent.com/login?return_to=%2Fpython-sdbus%2Fpython-sdbus-networkmanager
Star 43 https://patch-diff.githubusercontent.com/login?return_to=%2Fpython-sdbus%2Fpython-sdbus-networkmanager
Code https://patch-diff.githubusercontent.com/python-sdbus/python-sdbus-networkmanager
Issues 2 https://patch-diff.githubusercontent.com/python-sdbus/python-sdbus-networkmanager/issues
Pull requests 1 https://patch-diff.githubusercontent.com/python-sdbus/python-sdbus-networkmanager/pulls
Discussions https://patch-diff.githubusercontent.com/python-sdbus/python-sdbus-networkmanager/discussions
Actions https://patch-diff.githubusercontent.com/python-sdbus/python-sdbus-networkmanager/actions
Security 0 https://patch-diff.githubusercontent.com/python-sdbus/python-sdbus-networkmanager/security
Insights https://patch-diff.githubusercontent.com/python-sdbus/python-sdbus-networkmanager/pulse
Code https://patch-diff.githubusercontent.com/python-sdbus/python-sdbus-networkmanager
Issues https://patch-diff.githubusercontent.com/python-sdbus/python-sdbus-networkmanager/issues
Pull requests https://patch-diff.githubusercontent.com/python-sdbus/python-sdbus-networkmanager/pulls
Discussions https://patch-diff.githubusercontent.com/python-sdbus/python-sdbus-networkmanager/discussions
Actions https://patch-diff.githubusercontent.com/python-sdbus/python-sdbus-networkmanager/actions
Security https://patch-diff.githubusercontent.com/python-sdbus/python-sdbus-networkmanager/security
Insights https://patch-diff.githubusercontent.com/python-sdbus/python-sdbus-networkmanager/pulse
Answered https://patch-diff.githubusercontent.com/python-sdbus/python-sdbus-networkmanager/discussions/73#discussioncomment-13122191
igo95862https://patch-diff.githubusercontent.com/igo95862
benjamin-grzimek https://patch-diff.githubusercontent.com/benjamin-grzimek
Q&Ahttps://patch-diff.githubusercontent.com/python-sdbus/python-sdbus-networkmanager/discussions/categories/q-a
Register a new secret agent https://patch-diff.githubusercontent.com/python-sdbus/python-sdbus-networkmanager/discussions/73#top
benjamin-grzimek https://patch-diff.githubusercontent.com/benjamin-grzimek
Answered https://patch-diff.githubusercontent.com/python-sdbus/python-sdbus-networkmanager/discussions/73#discussioncomment-13122191
igo95862https://patch-diff.githubusercontent.com/igo95862
Return to tophttps://patch-diff.githubusercontent.com/python-sdbus/python-sdbus-networkmanager/discussions/73#top
Please reload this pagehttps://patch-diff.githubusercontent.com/python-sdbus/python-sdbus-networkmanager/discussions/73
https://patch-diff.githubusercontent.com/python-sdbus/python-sdbus-networkmanager/discussions/73
benjamin-grzimek https://patch-diff.githubusercontent.com/benjamin-grzimek
May 6, 2025 https://patch-diff.githubusercontent.com/python-sdbus/python-sdbus-networkmanager/discussions/73#discussion-8284371
Give feedback.https://patch-diff.githubusercontent.com/python-sdbus/python-sdbus-networkmanager/discussions/73
igo95862 https://patch-diff.githubusercontent.com/igo95862
May 12, 2025 https://github.com/python-sdbus/python-sdbus-networkmanager/discussions/73#discussioncomment-13122191
View full answer https://patch-diff.githubusercontent.com/python-sdbus/python-sdbus-networkmanager/discussions/73#discussioncomment-13122191
Oldest https://patch-diff.githubusercontent.com/python-sdbus/python-sdbus-networkmanager/discussions/73?sort=old
Newest https://patch-diff.githubusercontent.com/python-sdbus/python-sdbus-networkmanager/discussions/73?sort=new
Top https://patch-diff.githubusercontent.com/python-sdbus/python-sdbus-networkmanager/discussions/73?sort=top
Please reload this pagehttps://patch-diff.githubusercontent.com/python-sdbus/python-sdbus-networkmanager/discussions/73
https://patch-diff.githubusercontent.com/python-sdbus/python-sdbus-networkmanager/discussions/73
igo95862 https://patch-diff.githubusercontent.com/igo95862
May 6, 2025 https://patch-diff.githubusercontent.com/python-sdbus/python-sdbus-networkmanager/discussions/73#discussioncomment-13052091
@benjamin-grzimekhttps://github.com/benjamin-grzimek
https://www.networkmanager.dev/docs/api/latest/gdbus-org.freedesktop.NetworkManager.SecretAgent.htmlhttps://www.networkmanager.dev/docs/api/latest/gdbus-org.freedesktop.NetworkManager.SecretAgent.html
Give feedback.https://patch-diff.githubusercontent.com/python-sdbus/python-sdbus-networkmanager/discussions/73
https://patch-diff.githubusercontent.com/benjamin-grzimek
Please reload this pagehttps://patch-diff.githubusercontent.com/python-sdbus/python-sdbus-networkmanager/discussions/73
https://patch-diff.githubusercontent.com/python-sdbus/python-sdbus-networkmanager/discussions/73
benjamin-grzimekhttps://patch-diff.githubusercontent.com/benjamin-grzimek
May 12, 2025 https://patch-diff.githubusercontent.com/python-sdbus/python-sdbus-networkmanager/discussions/73#discussioncomment-13115851
python-networkmanagerhttps://github.com/seveas/python-networkmanager/blob/main/examples/otp-agent
Give feedback.https://patch-diff.githubusercontent.com/python-sdbus/python-sdbus-networkmanager/discussions/73
https://patch-diff.githubusercontent.com/igo95862
Please reload this pagehttps://patch-diff.githubusercontent.com/python-sdbus/python-sdbus-networkmanager/discussions/73
https://patch-diff.githubusercontent.com/python-sdbus/python-sdbus-networkmanager/discussions/73
Please reload this pagehttps://patch-diff.githubusercontent.com/python-sdbus/python-sdbus-networkmanager/discussions/73
https://patch-diff.githubusercontent.com/python-sdbus/python-sdbus-networkmanager/discussions/73
igo95862https://patch-diff.githubusercontent.com/igo95862
May 12, 2025 https://patch-diff.githubusercontent.com/python-sdbus/python-sdbus-networkmanager/discussions/73#discussioncomment-13122191
Give feedback.https://patch-diff.githubusercontent.com/python-sdbus/python-sdbus-networkmanager/discussions/73
benjamin-grzimekhttps://patch-diff.githubusercontent.com/benjamin-grzimek
https://patch-diff.githubusercontent.com/igo95862
Please reload this pagehttps://patch-diff.githubusercontent.com/python-sdbus/python-sdbus-networkmanager/discussions/73
https://patch-diff.githubusercontent.com/python-sdbus/python-sdbus-networkmanager/discussions/73
igo95862https://patch-diff.githubusercontent.com/igo95862
May 12, 2025 https://patch-diff.githubusercontent.com/python-sdbus/python-sdbus-networkmanager/discussions/73#discussioncomment-13122235
Give feedback.https://patch-diff.githubusercontent.com/python-sdbus/python-sdbus-networkmanager/discussions/73
https://patch-diff.githubusercontent.com/benjamin-grzimek
Please reload this pagehttps://patch-diff.githubusercontent.com/python-sdbus/python-sdbus-networkmanager/discussions/73
https://patch-diff.githubusercontent.com/python-sdbus/python-sdbus-networkmanager/discussions/73
benjamin-grzimekhttps://patch-diff.githubusercontent.com/benjamin-grzimek
May 15, 2025 https://patch-diff.githubusercontent.com/python-sdbus/python-sdbus-networkmanager/discussions/73#discussioncomment-13161025
Give feedback.https://patch-diff.githubusercontent.com/python-sdbus/python-sdbus-networkmanager/discussions/73
Sign up for freehttps://patch-diff.githubusercontent.com/join?source=comment-repo
Sign in to commenthttps://patch-diff.githubusercontent.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython-sdbus%2Fpython-sdbus-networkmanager%2Fdiscussions%2F73
🙏 Q&A https://patch-diff.githubusercontent.com/python-sdbus/python-sdbus-networkmanager/discussions/categories/q-a
https://patch-diff.githubusercontent.com/benjamin-grzimek
https://patch-diff.githubusercontent.com/igo95862
https://patch-diff.githubusercontent.com/python-sdbus/python-sdbus-networkmanager/discussions/73
https://patch-diff.githubusercontent.com/settings/replies?return_to=1
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.