okta-sdk-php
okta-sdk-php copied to clipboard
assignUserToApplication() InvalidArgumentException with message 'First argument to Stream::create() must be a string, resource or StreamInterface.'
I'm having trouble using the application assignUserToApplication method, which requires an AppUser.
Here is my current code:
$oktaAppUser = new \Okta\Applications\AppUser();
$oktaAppUser->setId($oktaUserId);
$oktaAppUser->setScope("USER");
$oktaApp = $this->getApplication($oktaApplicationId);
$oktaApp->assignUserToApplication($oktaAppUser);
This returns the following error: InvalidArgumentException with message 'First argument to Stream::create() must be a string, resource or StreamInterface.'
Am i initiating this incorrecly? I can retrieve 'read-only' items from $oktaApp like getApplicationUsers, etc.
Thanks in advance! PS - this might be related to https://github.com/okta/okta-sdk-php/issues/133
For future readers - i was able to bypass that method and call the api directly through the okta-sdk.
$uri = "/api/v1/apps/{$oktaApplicationId}/users";
$uri = $this->client->getDataStore()->buildUri(
$this->client->getDataStore()->getOrganizationUrl() . $uri
);
$body = $clientBuilder
->getDataStore()
->executeRequest('POST', $uri, json_encode(["id" => $oktaUserId]));
Would still love to know how to use the sdk directly.