Setting ?context=edit results in rest_forbidden_context, even for an Administrator user

Clearly your administrator is unable to modify those posts according to the roles and capabilities system.

This is the code that is generating that error in WP_REST_Post_Types_Controller:

    public function get_items_permissions_check( $request ) {
        if ( 'edit' === $request['context'] ) {
            $types = get_post_types( array( 'show_in_rest' => true ), 'objects' );

            foreach ( $types as $type ) {
                if ( current_user_can( $type->cap->edit_posts ) ) {
                    return true;
                }
            }

            return new WP_Error(
                'rest_cannot_view',
                __( 'Sorry, you are not allowed to edit posts in this post type.' ),
                array( 'status' => rest_authorization_required_code() )
            );
        }

        return true;
    }

So the user your python application is interacting as, does not have the edit_posts capability. Assuming it was succesfully authenticating.

What I think has happened here is that you are making unauthenticated requests, under the assumption they are authenticated. Somewhere along the line a mistake was made, perhaps a header is not being applied to your requests, etc.

Either way, what you describe is normal behaviour for an unauthenticated client. I would take a closer look at your python library. For something as simple as basic auth REST API a generic REST API library may be more appropriate and reliable.

Also keep in mind it’s not enough to use basic authentication, a plugin needs to be installed and activated at the WP end. WP 5.6 also adds application password support as a more secure alternative