Jump to content

create a new user with emby api


Recommended Posts

Posted

"I want to use the Emby API to create a new user and copy configurations from a specified user. Does the official API support this?"

hthgihwaymonk
Posted (edited)

you'll want to look at the `emby/Users/New` endpoint and in the payload include at least -
 

"CopyFromUserId": "{specified user}",
"UserCopyOptions": [
"UserPolicy"
]

 

Edited by hthgihwaymonk
  • Thanks 1
Posted
1 hour ago, hthgihwaymonk said:

you'll want to look at the `emby/Users/New` endpoint and in the payload include at least -
 

"CopyFromUserId": "{specified user}",
"UserCopyOptions": [
"UserPolicy"
]

 

Thank you very much for your response. I know how to create users, open-source specified copying of specified user policies, but there is no copying of user configurations.

hthgihwaymonk
Posted

what type of configurations are you wanting to copy ?

 

Happy2Play
Posted

I will guess the example is just not showing you both options.  So add "UserConfiguration"

Enum UserCopyOptions (emby.media)

  • Agree 1
Posted
22 minutes ago, Happy2Play said:

I will guess the example is just not showing you both options.  So add "UserConfiguration"

Enum UserCopyOptions (emby.media)

{
  "Name": "string",
  "CopyFromUserId": "d6394c9ad8b14e77b458bff6df92176c",
  "UserCopyOptions": [
    "UserPolicy"
  ],[
    "UserConfiguration"
  ]
}

I don't know what the format of UserConfiguration is.

bakes82
Posted

So use the UI and look at the post call it pretty much tells you what you need to do:

 

{
  "Name": "string",
  "CopyFromUserId": "string",
  "UserCopyOptions": [
    "UserPolicy", "UserConfiguration"
  ]
}

Happy2Play
Posted
8 minutes ago, slove said:
{
  "Name": "string",
  "CopyFromUserId": "d6394c9ad8b14e77b458bff6df92176c",
  "UserCopyOptions": [
    "UserPolicy"
  ],[
    "UserConfiguration"
  ]
}

I don't know what the format of UserConfiguration is.

I just tested this

{
  "Name": "NEW",
  "CopyFromUserId": "{myuserid}",
  "UserCopyOptions": [
    "UserConfiguration",
    "UserPolicy"
  ]
}

 

Posted
3 minutes ago, Happy2Play said:

I just tested this

{
  "Name": "NEW",
  "CopyFromUserId": "{myuserid}",
  "UserCopyOptions": [
    "UserConfiguration",
    "UserPolicy"
  ]
}

{
  "Name": "NEW",
  "CopyFromUserId": "d6394c9ad8b14e77b458bff6df92176c",
  "UserCopyOptions": [
    "UserConfiguration",
    "UserPolicy"
  ]
}This error message translates to: "Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)."

 

Happy2Play
Posted
21 minutes ago, slove said:

Emby Server 4.8.0.56 

Is there a reason you are on what I believe is an obsolete beta version?

Posted
On 4/4/2024 at 2:40 AM, hthgihwaymonk said:

what type of configurations are you wanting to copy ?

 

Thank you very much for your response

Posted
On 4/4/2024 at 3:49 AM, Happy2Play said:

Is there a reason you are on what I believe is an obsolete beta version?

thanks for you help

Posted

Hi, have you updated to the latest build?

Posted
8 hours ago, Luke said:

Hi, have you updated to the latest build?

There is a question, create a new user, copy the user policy and configuration from the specified user, what is the minimum version supported, what is the format?

{
  "Name": "NEW",
  "CopyFromUserId": "d6394c9ad8b14e77b458bff6df92176c",
  "UserCopyOptions": [
    "UserConfiguration",
    "UserPolicy"
  ]
} or

{
  "Name": "NEW",
  "CopyFromUserId": "d6394c9ad8-b14e-77b4-58bf-f6df92176c",
  "UserCopyOptions": [
    "UserConfiguration",
    "UserPolicy"
  ]
}

 

Which is correct

Happy2Play
Posted

Did you update to current release/current beta?  Or are you still on old beta 4.8.0.56?

But I would say what does the userid look like via the api when you query that user?

Posted (edited)

My server is Arm64 (aarch64), I chose docker and installed the version is 4.8.0.56, not sure the latest version supports arm64, so, I didn't upgrade

 

Edited by slove
Posted
16 minutes ago, Happy2Play said:

Did you update to current release/current beta?  Or are you still on old beta 4.8.0.56?

But I would say what does the userid look like via the api when you query that user?

My server is Arm64 (aarch64), I chose docker and installed the version is 4.8.0.56, not sure the latest version supports arm64, so, I didn't upgrade

Posted
57 minutes ago, slove said:

My server is Arm64 (aarch64), I chose docker and installed the version is 4.8.0.56, not sure the latest version supports arm64, so, I didn't upgrade

HI, the latest version does support aarch64.

Posted
22 minutes ago, Luke said:

HI, the latest version does support aarch64.

 

create a new user using the API, copy the user policy and configuration from the specified user, what is the minimum version supported

Posted
50 minutes ago, slove said:

 

create a new user using the API, copy the user policy and configuration from the specified user, what is the minimum version supported

That was added during 4.7 development. I don't remember exactly which 4.7.X version it was. Probably around 4.7.9.

Posted
On 4/6/2024 at 2:03 PM, Luke said:

That was added during 4.7 development. I don't remember exactly which 4.7.X version it was. Probably around 4.7.9.

thanks

  • 7 months later...
Posted

hii, i want to create user emby via api , The user has been successfully created, but cannot apply the password. does the api not support enforcing passwords? is there any error in my configuration.


    # Step 1: Create the user in Emby
    response = requests.post(
        f"{EMBY_URL}/emby/Users/New",
        headers=EMBY_HEADER,
        json={
            "Name": username,
            "IsAdministrator": False,
            "IsHidden": True
        }
    )
    
    logging.info(f"Emby API response status code (User Creation): {response.status_code}")
    logging.info(f"Emby API response body (User Creation): {response.text}")
    
    if response.status_code == 200:
        user_id = get_user_id(username)
        if user_id:
            # Step 2: Set the user's password
            try:
                password_response = requests.post(
                    f"{EMBY_URL}/emby/Users/{user_id}/Password",
                    headers=EMBY_HEADER,
                    json={"CurrentPassword": "", "NewPassword": password}
                )
                password_response.raise_for_status()
                logging.info(f"Password set successfully for user '{username}'.")
            except Exception as e:
                logging.error(f"Error setting password for '{username}': {e}")
                await update.message.reply_text(f"Failed to set password for '{username}'.")
                return
            
            # Step 3: Update user configuration if password was successfully set
            try:
                config_response = requests.post(
                    f"{EMBY_URL}/emby/Users/{user_id}/Policy",
                    headers=EMBY_HEADER,
                    json={
                        "IsAdministrator": False,
                        "IsHidden": False,
                        "IsHiddenRemotely": True,
                        "IsHiddenFromUnusedDevices": False,
                        "IsDisabled": False,
                        "LockedOutDate": 0,
                        "AllowTagOrRating": False,
                        "BlockedTags": [],
                        "IsTagBlockingModeInclusive": False,
                        "IncludeTags": [],
                        "EnableUserPreferenceAccess": True,
                        "AccessSchedules": [],
                        "BlockUnratedItems": [],
                        "EnableRemoteControlOfOtherUsers": False,
                        "EnableSharedDeviceControl": True,
                        "EnableRemoteAccess": True,
                        "EnableLiveTvManagement": True,
                        "EnableLiveTvAccess": True,
                        "EnableMediaPlayback": True,
                        "EnableAudioPlaybackTranscoding": True,
                        "EnableVideoPlaybackTranscoding": True,
                        "EnablePlaybackRemuxing": True,
                        "EnableContentDeletion": False,
                        "RestrictedFeatures": [],
                        "EnableContentDeletionFromFolders": [],
                        "EnableContentDownloading": True,
                        "EnableSubtitleDownloading": True,
                        "EnableSubtitleManagement": False,
                        "EnableSyncTranscoding": True,
                        "EnableMediaConversion": True,
                        "EnabledChannels": [],
                        "EnableAllChannels": True,
                        "EnabledFolders": [],
                        "EnableAllFolders": True,
                        "InvalidLoginAttemptCount": 0,
                        "EnablePublicSharing": True,
                        "RemoteClientBitrateLimit": 0,
                        "ExcludedSubFolders": [],
                        "SimultaneousStreamLimit": 0,
                        "EnabledDevices": [],
                        "EnableAllDevices": True,
                        "AllowCameraUpload": True,
                        "AllowSharingPersonalItems": False
                    }
                )
                config_response.raise_for_status()
                logging.info(f"Configuration updated successfully for user '{username}'.")
            except Exception as e:
                logging.error(f"Error updating configuration for '{username}': {e}")
                await update.message.reply_text(f"Failed to update configuration for '{username}'.")
                return

            

 

Posted

Respon api

 

{"Name":"aaa12","ServerId":"187e8c799f59462ebeb0f4d84b9b6a0e","Prefix":"A","DateCreated":"2024-11-18T06:54:14.1435392Z","Id":"f354199ebd394f428da69fcceeea22a2","HasPassword":false,"HasConfiguredPassword":false,"Configuration":{"PlayDefaultAudioTrack":true,"DisplayMissingEpisodes":false,"SubtitleMode":"Smart","OrderedViews":[],"LatestItemsExcludes":[],"MyMediaExcludes":[],"HidePlayedInLatest":true,"HidePlayedInMoreLikeThis":false,"HidePlayedInSuggestions":false,"RememberAudioSelections":true,"RememberSubtitleSelections":true,"EnableNextEpisodeAutoPlay":true,"ResumeRewindSeconds":0,"IntroSkipMode":"ShowButton","EnableLocalPassword":false},"Policy":{"IsAdministrator":false,"IsHidden":false,"IsHiddenRemotely":true,"IsHiddenFromUnusedDevices":false,"IsDisabled":false,"LockedOutDate":0,"AllowTagOrRating":false,"BlockedTags":[],"IsTagBlockingModeInclusive":false,"IncludeTags":[],"EnableUserPreferenceAccess":true,"AccessSchedules":[],"BlockUnratedItems":[],"EnableRemoteControlOfOtherUsers":false,"EnableSharedDeviceControl":true,"EnableRemoteAccess":true,"EnableLiveTvManagement":true,"EnableLiveTvAccess":true,"EnableMediaPlayback":true,"EnableAudioPlaybackTranscoding":true,"EnableVideoPlaybackTranscoding":true,"EnablePlaybackRemuxing":true,"EnableContentDeletion":false,"RestrictedFeatures":[],"EnableContentDeletionFromFolders":[],"EnableContentDownloading":true,"EnableSubtitleDownloading":true,"EnableSubtitleManagement":false,"EnableSyncTranscoding":true,"EnableMediaConversion":true,"EnabledChannels":[],"EnableAllChannels":true,"EnabledFolders":[],"EnableAllFolders":true,"InvalidLoginAttemptCount":0,"EnablePublicSharing":true,"RemoteClientBitrateLimit":0,"ExcludedSubFolders":[],"SimultaneousStreamLimit":0,"EnabledDevices":[],"EnableAllDevices":true,"AllowCameraUpload":true,"AllowSharingPersonalItems":false},"HasConfiguredEasyPassword":false}

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...