ImpersonationΒΆ

Things like moco_wrapper.models.Activity and moco_wrapper.models.UserPresence are always mapped to the user of the api key that was used.

If you want to change that (for example when logging activities on behalf of someone else), you can impersontate them.

Note

For impersonating other users your own user account must have the Staff permission. See https://github.com/hundertzehn/mocoapp-api-docs#impersonation.

You can start off the moco instance already impersonating a user:

from moco_wrapper import moco

impersonate_as = 43
m = Moco(
    ..,
    impersonate_user_id = impersonate_as
)

## do something as someone else
##
##

## reset impersonation
m.clear_impersonation()

Note

If you are authenticating yourself with email and password, that the first request (for authenticating you) will still take place as yourself, impersonation will only occur after you are already authenticated.

Or you can use the impersonte method by itself.

from moco_wrapper import Moco

m = Moco()

## do something as you
##
##

impersonate_as = 43
m.impersonate(impersonate_as)

## do something as someone else
##
##

## reset impersonation
m.clear_impersonation()