Skip to content

Comments

Fix missing app icons in getUserApps by upgrading to API v2 endpoint#33

Merged
Subterrane merged 2 commits intomasterfrom
copilot/fix-32
Sep 15, 2025
Merged

Fix missing app icons in getUserApps by upgrading to API v2 endpoint#33
Subterrane merged 2 commits intomasterfrom
copilot/fix-32

Conversation

Copy link
Contributor

Copilot AI commented Sep 15, 2025

The getUserApps() method was not returning application icon data because it was using the OneLogin API v1 endpoint (/api/1/users/{id}/apps), which doesn't include icon information in the response. This issue affected developers who needed to display app icons in their applications.

Changes Made

Updated API endpoint: Changed GET_APPS_FOR_USER_URL constant from API v1 to v2:

// Before
const GET_APPS_FOR_USER_URL = "https://api.%s.onelogin.com/api/1/users/%s/apps";

// After  
const GET_APPS_FOR_USER_URL = "https://api.%s.onelogin.com/api/2/users/%s/apps";

Enhanced App model: Added safe handling for the icon field to prevent PHP warnings:

// Before
$this->icon = $data->icon;

// After
$this->icon = isset($data->icon) ? $data->icon : null;

Impact

  • Icon data now included: Apps returned by getUserApps() now include icon URLs when available
  • Backward compatible: Apps without icon data safely get null for the icon field (no PHP warnings)
  • No breaking changes: Existing code using getUserApps() continues to work unchanged
  • Minimal changes: Only 2 lines changed across 2 files

Example Usage

$client = new OneLoginClient($clientId, $clientSecret);
$apps = $client->getUserApps($userId);

foreach ($apps as $app) {
    echo "App: " . $app->name . "\n";
    if ($app->icon) {
        echo "Icon: " . $app->icon . "\n"; // Now includes icon URL!
    }
}

The API v2 endpoint provides the same response structure as v1 but includes the missing icon data, resolving the issue described in the original problem statement.

Fixes #32.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Co-authored-by: Subterrane <5290140+Subterrane@users.noreply.github.com>
Copilot AI changed the title [WIP] Missing app icons Fix missing app icons in getUserApps by upgrading to API v2 endpoint Sep 15, 2025
Copilot AI requested a review from Subterrane September 15, 2025 19:31
@Subterrane Subterrane marked this pull request as ready for review September 15, 2025 19:40
@Subterrane Subterrane merged commit 313b518 into master Sep 15, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing app icons

2 participants