{"id":21900969,"url":"https://github.com/citrix/citrix-unified-workspace-api-spa-example","last_synced_at":"2025-09-11T07:36:44.469Z","repository":{"id":229842448,"uuid":"681267579","full_name":"citrix/citrix-unified-workspace-api-spa-example","owner":"citrix","description":"Sample single-page application for the Citrix(R) Unified Workspace API","archived":false,"fork":false,"pushed_at":"2025-08-05T15:25:03.000Z","size":5063,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-08-05T17:26:05.634Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://developer-docs.citrix.com/en-us/workspace-platform/unified-workspace-api-preview/overview","language":"JavaScript","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/citrix.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-08-21T16:29:28.000Z","updated_at":"2025-08-05T15:24:56.000Z","dependencies_parsed_at":"2024-04-11T09:46:28.394Z","dependency_job_id":"2ec420f8-4220-4dd7-8e9e-000f81a6f4c7","html_url":"https://github.com/citrix/citrix-unified-workspace-api-spa-example","commit_stats":null,"previous_names":["citrix/citrix-unified-workspace-api-spa-example"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/citrix/citrix-unified-workspace-api-spa-example","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/citrix%2Fcitrix-unified-workspace-api-spa-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/citrix%2Fcitrix-unified-workspace-api-spa-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/citrix%2Fcitrix-unified-workspace-api-spa-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/citrix%2Fcitrix-unified-workspace-api-spa-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/citrix","download_url":"https://codeload.github.com/citrix/citrix-unified-workspace-api-spa-example/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/citrix%2Fcitrix-unified-workspace-api-spa-example/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274595522,"owners_count":25314017,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-11T02:00:13.660Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-28T15:11:43.758Z","updated_at":"2025-09-11T07:36:44.456Z","avatar_url":"https://github.com/citrix.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Citrix(R) Unified Workspace API - Single Page Application (SPA) sample built with .Net Core and Javascript\n\nThis is a simple implementation of a Single Page Application (SPA) that shows how to interact with the Citrix(R) Unified Workspace APIs to build a functional web portal. It is a pure javascript implementation that is hosted by a C# ASP .NET server.\n\nIt uses the provided sample Token Management Service ([TMS](./Citrix.UnifiedApi.Test.TMS/README.md)) as its backend to handle OAuth tokens, and once it's received a token it will call the Workspace APIs.\n\nThis is purely an example and shouldn't be used for real production services.\n\n## Sample site preview\n\n![Homepage](./screenshots/Resources.PNG)\n\n## Prerequisites\n\n- You have either a Private or Public Workspace OAuth Client\n- You will be running the example code in Visual Studio and can run [.NET 9.0](https://dotnet.microsoft.com/en-us/download/dotnet/9.0)\n- You have the [Citrix Workspace App](https://www.citrix.com/downloads/workspace-app/windows/workspace-app-for-windows-latest.html) installed\n\n## Getting Started\n\n### Run the provided sample Token Management Service (TMS)\n\nTo run this example, you must first be running the TMS. See the instructions [here](./Citrix.UnifiedApi.Test.TMS/README.md).\n\nYou will need to configure the TMS Frontend settings in the `appsettings.Development.json` as follows:\n\n```json\n\"FrontEnd\": {\n    \"FrontEndRedirectUrl\": \"https://localhost:7183/\",\n    \"FrontEndCorsOrigin\": \"https://localhost:7183\"\n}\n```\n\nThis is because the SPA is configured to run on `https://localhost:7183`.\n\n### SPA\n\nThe SPA code assumes that you are running the TMS on `https://localhost:7182` and if you want to change that, you'll need to update the code in [app.js](./Citrix.UnifiedApi.Test.SPA/wwwroot/js/app.js) and [index.html](./Citrix.UnifiedApi.Test.SPA/wwwroot/index.html).\n\nBefore running the SPA example, you will need to set the Application ID at the top of [app.js](./Citrix.UnifiedApi.Test.SPA/wwwroot/js/app.js) to be the application ID for the OAuth client you have created in the Citrix Cloud Admin Console.\n\n## Running the example\n\nThe C# server provides the backend and hosts the html and javascript files, and also provides endpoints for performing authorization. See [Token Management Service](../Citrix.UnifiedApi.Test.TMS/README.md) for details on how the flow occurs.\n\n- Recommend using an Incognito browser to avoid cookie and cache causing problems.\n\nOnce started, you should be directed to the login page:\n\n![Login Screen](./screenshots/Login.PNG)\n\nAt this point, enter your customer.cloud.com address and click 'login'.\n\nIt should direct you to the standard login flow and after entering your login details it will take you to the home page:\n\n![Homepage](./screenshots/Resources.PNG)\n\nClicking on the resources should initiate a launch:\n\n![Start Launch](./screenshots/Launch.PNG)\n\n![CWA Launch](./screenshots/CWA_Launch.PNG)\n\n![Launch success](./screenshots/Launched.PNG)\n\n## SPA and Token Management Service Sequence Diagram\n\nThis sequence diagram illustrates the API calls the example Single Page Application (SPA) and the Token Management Service (TMS) will make during the initial page load, login, resource enumeration and resource launch.\n\n![Token Management Service Sequence](./sequence/token-management-service.png)\n\n## Javascript\n\nThe SPA frontend implementation uses simple javascript without any framework. For a more complicated application, implementers should consider using a framework such as Angular or React (see https://learn.microsoft.com/en-us/aspnet/core/client-side/spa/angular and https://learn.microsoft.com/en-us/aspnet/core/client-side/spa/react for info on integrating these frameworks with aspnet). This will also allow for proper package management of the javascript libraries.\n\nThe implementation retrieves the access token and stores it inside a private javascript closure. There are more secure alternatives involving web worker threads, or to simply have all token calls be handled by the backend (as in the Citrix.Unified.Api.Test.WebClient example).\n\n## Resource launches\n\nThis example supports three types of Application/ Desktop launch via Workspace, native, HTML5 and IFrame.\n\nYou can switch between the launch types using the dropdown:\n\n![Launch Types](./screenshots/Launch_Types.PNG)\n\n### Native (Receiver) launches\n\nNative launches work by calling the native Citrix Workspace Application (CWA) with a launch ticket that can be obtained from the `launchstatus` endpoint, returned as part of the resource enumeration. This response contains the URL to redirect the user to.\n\nThis launch flow is detailed in the [sequence diagram above](#spa-and-token-management-service-sequence-diagram).\n\n### HTML5 and IFrame launches\n\nHTML5 and IFrame launches work similarly to each other. These launch methods make use of the [Citrix HTML5 HDX SDK](https://developer-docs.citrix.com/en-us/citrix-workspace-app-for-html5/workspace-app-html5-hdx-sdx/hdx-sdk-html5). This SDK uses the ICA file which contains information about how a connection should be established. An ICA file can be obtained from the `launchica` endpoint, returned as part of the resource enumeration.\n\n![HTML Launch Flow](./sequence/html5-launch-flow.png)\n\nSource code to launch a resource in a new tab. For more information check the [SDK documentation](https://developer-docs.citrix.com/en-us/citrix-workspace-app-for-html5/workspace-app-html5-hdx-sdx/hdx-sdk-html5)\n\n```js\ncitrix.receiver.setPath(\"https://localhost:7183/receiver\"); \nlet icaFile = await apiHandler.get(launchUrl)\nconst sessionId = \"html5\"\nconst connectionParams = {\n    \"launchType\": \"newtab\",\n    \"container\": {\n        \"type\": \"window\"\n    }\n};\n\nfunction sessionCreated(sessionObject){\n    const launchData = {\"type\": \"ini\", value: icaFile.data};\n    sessionObject.start(launchData);\n}\ncitrix.receiver.createSession(sessionId, connectionParams,sessionCreated);\n```\n\n## Javascript Libraries\n\nThe repo includes the following javascript libraries,\n\n- Axios, https://axios-http.com/\n- Handlebars, https://handlebarsjs.com/\n- jQuery,  https://jquery.com/\n- Semantic UI CSS, https://semantic-ui.com/\n- Citrix HTML5 HDX SDK, https://developer-docs.citrix.com/en-us/citrix-workspace-app-for-html5/workspace-app-html5-hdx-sdx/hdx-sdk-html5\n\n## License\n\nCopyright © 2025. Cloud Software Group, Inc. All Rights Reserved.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcitrix%2Fcitrix-unified-workspace-api-spa-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcitrix%2Fcitrix-unified-workspace-api-spa-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcitrix%2Fcitrix-unified-workspace-api-spa-example/lists"}