civicrm / org.civicrm.api4

CiviCRM api version 4
Other
8 stars 19 forks source link

Authorization failed for anoymous WordPress User #205

Closed skyslasher closed 4 years ago

skyslasher commented 5 years ago

When using \Civi\Api4\Contact::getFields() or \Civi\Api4\Contact::get() on a WordPress page accessed by an anonymous (not loggend in) user, the call fails with "Authorization failed". Using the same call with API3 succeeds. Only when granting "Perform all tasks in the Administer CiviCRM control panel and Import Contacts" the API4 call succeeds.

skyslasher commented 5 years ago

API-Version is 4.4.3, CiviCRM is 5.17.4

Sample Code: $fields = \Civi\Api4\Contact::getFields() ->setLoadOptions( true ) ->setSelect( [ 'options', 'name' ] ) ->addWhere( 'name', 'IN', $options ) ->setCheckPermissions( false ) ->execute(); Same result on setCheckPermissions set to false or true.

bhahumanists commented 5 years ago

Yes, seeing this here too, with or without setCheckPermissions(). Civi 5.13.5, API version 4.4.3, and latest WordPress.

colemanw commented 5 years ago

@skyslasher that's not good. I wonder if you'd be able to upgrade to CiviCRM 5.18 + API 4.5.2 and try again?

bhahumanists commented 4 years ago

Can confirm this is solved by updating to Civi 5.19.

colemanw commented 4 years ago

Hooray!

skyslasher commented 4 years ago

Can confirm it works with API 4.4.3 on Civi 5.19.1. Thanks!