From 8c1e50d9e7d01608729350a66bf94f0fd8833349 Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Mon, 23 Sep 2024 14:32:36 -0700 Subject: [PATCH] Enhancement: support photoprism app passwords (#4028) --- docs/widgets/services/photoprism.md | 9 ++++++--- src/widgets/photoprism/proxy.js | 5 +++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/docs/widgets/services/photoprism.md b/docs/widgets/services/photoprism.md index c6e9c3f66..afb396069 100644 --- a/docs/widgets/services/photoprism.md +++ b/docs/widgets/services/photoprism.md @@ -3,7 +3,9 @@ title: PhotoPrism description: PhotoPrism Widget Configuration --- -Learn more about [PhotoPrism](https://github.com/photoprism/photoprism).. +Learn more about [PhotoPrism](https://github.com/photoprism/photoprism). + +Authentication is possible via [app passwords](https://docs.photoprism.app/user-guide/settings/account/#apps-and-devices) or username/password. Allowed fields: `["albums", "photos", "videos", "people"]`. @@ -11,6 +13,7 @@ Allowed fields: `["albums", "photos", "videos", "people"]`. widget: type: photoprism url: http://photoprism.host.or.ip:port - username: admin - password: password + username: admin # required only if using username/password + password: password # required only if using username/password + key: # required only if using app passwords ``` diff --git a/src/widgets/photoprism/proxy.js b/src/widgets/photoprism/proxy.js index 5aca37756..509bfa0c7 100644 --- a/src/widgets/photoprism/proxy.js +++ b/src/widgets/photoprism/proxy.js @@ -32,6 +32,11 @@ export default async function photoprismProxyHandler(req, res) { username: widget.username, password: widget.password, }); + } else if (widget.key) { + params.headers.Authorization = `Bearer ${widget.key}`; + params.body = JSON.stringify({ + authToken: widget.key, + }); } const [status, contentType, data] = await httpProxy(url, params);