Ponytech / appstoreconnectapi

Python wrapper around Apple App Store Api

Home Page:https://ponytech.net/projects/app-store-connect

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to modify user roles

yangcaixing opened this issue · comments

Hi Pony,
I want to modify an existing user's roles (role and visibleApps), not invite new user. I look from appstore api document, it contain "Modify a User Account" api, but I don't find the related code from your api.py file. would please have a check, thanks very much.

@yangcaixing Thanks for reporting this. You're right modifying and removing a user account are missing from the library, I am working on it to add them.

Thanks pony, I'm looking forward to your update.

@yangcaixing I have just made a new commit that allows to modify a user's role. You can try with:

from appstoreconnect import Api, UserRole

user = list(api.list_users())[0]
api.modify_user_account(user, roles=[UserRole.FINANCE, UserRole.APP_MANAGER, UserRole.ACCESS_TO_REPORTS])

I still have to add support for updating the visibleApps

Well, I've also handled visibleApps :

	apps = api.list_apps(filters={ 'name': 'My great app'})
	app = list(apps)[0]
        user = list(api.list_users())[0]
	user = api.modify_user_account(user, visibleApps=[app])

Let me know if everything works as expected before I close this issue.

Hi pony,
I have update appstoreconnect to v0.8.4, run the code have bellow errors. and I also check from the library api.py file, there no modify_user_account function existed, could you please check again, thanks.

Traceback (most recent call last):
File "appstore.py", line 4, in
from appstoreconnect import Api, UserRole
ImportError: cannot import name 'UserRole'

Traceback (most recent call last):
File "appstore.py", line 40, in
api.modify_user_account(user, roles=[UserRole.FINANCE, UserRole.APP_MANAGER, UserRole.ACCESS_TO_REPORTS])
AttributeError: 'Api' object has no attribute 'modify_user_account'
image

I have update appstoreconnect to v0.8.4

The modify_user_account endpoint is not yet included in a release published on PyPI. You have to checkout this repository to test it.

Hi pony, I have checkout the repo and test, it works now, thanks very much.

I have checkout the repo and test, it works now,

Great! I am closing the issue then. I'll publish a new version including it soon.

Hi Pony,
BTW, I want to list a use's visibleApps, to check if user have some specific app's roles, but I don't find the visibleApps attribute under apple User.Attributes, could you help check it , thanks.

Hi @yangcaixing,

BTW, my name is not Pony 😄 I am Patrice.

You should be able to get a user's visible apps with: user.visibleApps() but it currently doesn't work. I have to implement the VisibleApps resource (https://developer.apple.com/documentation/appstoreconnectapi/user/relationships/visibleapps)
You can open a separate issue for this.

Hi Patrice,
I'm sorry for call your name wrong, and I will open a new issue for this, thanks.