If I use login and password to auth I get "vk_api.exceptions.ApiError: [203] Access to group denied"
If I use access token I get "vk_api.exceptions.ApiError: [27] Group authorization failed: method is unavailable with group auth."
First way:
def upload_pic(filename, album_id, group_id):
vk_session = vk_api.VkApi(login=LOGIN, password=PASSWORD)
try:
vk_session.auth(token_only=True)
except vk_api.AuthError as error_msg:
print(error_msg)
return
upload = vk_api.VkUpload(vk_session)
upload.photo(filename, album_id, group_id=group_id)
Second way:
def upload_pic(filename, album_id, group_id):
vk_session = vk_api.VkApi(token=TOKEN)
upload = vk_api.VkUpload(vk_session)
upload.photo(filename, album_id, group_id=group_id)
I tried to add auth block from first way to second one but it nothing changed rights for token
I'm not sure that this is the reason but i remembered that vk_api uses keyword args
In general here's the working code
def upload_pic(filename, album_id, group_id):
vk_session = vk_api.VkApi(login=LOGIN, password=PASSWORD)
try:
vk_session.auth(token_only=True)
except vk_api.AuthError as error_msg:
print(error_msg)
return
upload = vk_api.VkUpload(vk_session)
upload.photo(filename, album_id=album_id, group_id=group_id)