refreshProfiles

abstract suspend fun refreshProfiles(hostToken: String): CgsResult<Unit>

Syncs the account's profiles from the backend.

The SDK learns them at authenticate and does not go looking again, so a profile removed on your side stays known to it for the life of the session. Call this when you know your profiles have changed.

The refreshed list is not returned, and there is no accessor for it: you already know your own profiles. The SDK holds them only to notice that the active one has gone, and to choose for a host that asked it to.

If the active profile is no longer on the list, it is dropped and the session returns to account scope — the only case in which the SDK changes who is reading. Leaving it in place would keep sending an id the backend no longer knows. It is not replaced: choosing stays yours, so offer the user the choice again. Everything observed through Content reloads at account scope on its own in the meantime.

The exception is a host that asked the SDK to choose, which has no picker to offer: there the first of the remaining profiles is adopted in the dropped one's place. A profile still on the list stays active either way — a reordering does not move a reader.

Also supported, and unchanged, when the SDK manages profiles: this is how such a host tells the SDK its list has changed.

Nothing is refreshed automatically — when to call this is yours to decide.

Return

CgsResult.Success when the stored list has been replaced; CgsResult.Failure with the reason otherwise. A failure leaves the previously known profiles in place rather than clearing them.

A rejected hostToken comes back as co.cafeyn.cgs.api.errors.CgsError.Auth.Unauthorized and leaves the session open — the SDK's own tokens are still good, it is your token that needs replacing, so obtain a fresh one and call authenticate again.

Parameters

hostToken

the same token you pass to authenticate.