{"id":"570bce0d-14d6-4e1e-b247-5c6d90a1234f","shortId":"Eqekpv","kind":"skill","title":"azure-communication-common-java","tagline":"Azure Communication Services common utilities for Java. Use when working with CommunicationTokenCredential, user identifiers, token refresh, or shared authentication across ACS services.","description":"# Azure Communication Common (Java)\n\nShared authentication utilities and data structures for Azure Communication Services.\n\n## Installation\n\n```xml\n<dependency>\n    <groupId>com.azure</groupId>\n    <artifactId>azure-communication-common</artifactId>\n    <version>1.4.0</version>\n</dependency>\n```\n\n## Key Concepts\n\n| Class | Purpose |\n|-------|---------|\n| `CommunicationTokenCredential` | Authenticate users with ACS services |\n| `CommunicationTokenRefreshOptions` | Configure automatic token refresh |\n| `CommunicationUserIdentifier` | Identify ACS users |\n| `PhoneNumberIdentifier` | Identify PSTN phone numbers |\n| `MicrosoftTeamsUserIdentifier` | Identify Teams users |\n| `UnknownIdentifier` | Generic identifier for unknown types |\n\n## CommunicationTokenCredential\n\n### Static Token (Short-lived Clients)\n\n```java\nimport com.azure.communication.common.CommunicationTokenCredential;\n\n// Simple static token - no refresh\nString userToken = \"<user-access-token>\";\nCommunicationTokenCredential credential = new CommunicationTokenCredential(userToken);\n\n// Use with Chat, Calling, etc.\nChatClient chatClient = new ChatClientBuilder()\n    .endpoint(\"https://<resource>.communication.azure.com\")\n    .credential(credential)\n    .buildClient();\n```\n\n### Proactive Token Refresh (Long-lived Clients)\n\n```java\nimport com.azure.communication.common.CommunicationTokenRefreshOptions;\nimport java.util.concurrent.Callable;\n\n// Token refresher callback - called when token is about to expire\nCallable<String> tokenRefresher = () -> {\n    // Call your server to get a fresh token\n    return fetchNewTokenFromServer();\n};\n\n// With proactive refresh\nCommunicationTokenRefreshOptions refreshOptions = new CommunicationTokenRefreshOptions(tokenRefresher)\n    .setRefreshProactively(true)      // Refresh before expiry\n    .setInitialToken(currentToken);    // Optional initial token\n\nCommunicationTokenCredential credential = new CommunicationTokenCredential(refreshOptions);\n```\n\n### Async Token Refresh\n\n```java\nimport java.util.concurrent.CompletableFuture;\n\n// Async token fetcher\nCallable<String> asyncRefresher = () -> {\n    CompletableFuture<String> future = fetchTokenAsync();\n    return future.get();  // Block until token is available\n};\n\nCommunicationTokenRefreshOptions options = new CommunicationTokenRefreshOptions(asyncRefresher)\n    .setRefreshProactively(true);\n\nCommunicationTokenCredential credential = new CommunicationTokenCredential(options);\n```\n\n## Entra ID (Azure AD) Authentication\n\n```java\nimport com.azure.identity.InteractiveBrowserCredentialBuilder;\nimport com.azure.communication.common.EntraCommunicationTokenCredentialOptions;\nimport java.util.Arrays;\nimport java.util.List;\n\n// For Teams Phone Extensibility\nInteractiveBrowserCredential entraCredential = new InteractiveBrowserCredentialBuilder()\n    .clientId(\"<your-client-id>\")\n    .tenantId(\"<your-tenant-id>\")\n    .redirectUrl(\"<your-redirect-uri>\")\n    .build();\n\nString resourceEndpoint = \"https://<resource>.communication.azure.com\";\nList<String> scopes = Arrays.asList(\n    \"https://auth.msft.communication.azure.com/TeamsExtension.ManageCalls\"\n);\n\nEntraCommunicationTokenCredentialOptions entraOptions = \n    new EntraCommunicationTokenCredentialOptions(entraCredential, resourceEndpoint)\n        .setScopes(scopes);\n\nCommunicationTokenCredential credential = new CommunicationTokenCredential(entraOptions);\n```\n\n## Communication Identifiers\n\n### CommunicationUserIdentifier\n\n```java\nimport com.azure.communication.common.CommunicationUserIdentifier;\n\n// Create identifier for ACS user\nCommunicationUserIdentifier user = new CommunicationUserIdentifier(\"8:acs:resource-id_user-id\");\n\n// Get raw ID\nString rawId = user.getId();\n```\n\n### PhoneNumberIdentifier\n\n```java\nimport com.azure.communication.common.PhoneNumberIdentifier;\n\n// E.164 format phone number\nPhoneNumberIdentifier phone = new PhoneNumberIdentifier(\"+14255551234\");\n\nString phoneNumber = phone.getPhoneNumber();  // \"+14255551234\"\nString rawId = phone.getRawId();              // \"4:+14255551234\"\n```\n\n### MicrosoftTeamsUserIdentifier\n\n```java\nimport com.azure.communication.common.MicrosoftTeamsUserIdentifier;\n\n// Teams user identifier\nMicrosoftTeamsUserIdentifier teamsUser = new MicrosoftTeamsUserIdentifier(\"<teams-user-id>\")\n    .setCloudEnvironment(CommunicationCloudEnvironment.PUBLIC);\n\n// For anonymous Teams users\nMicrosoftTeamsUserIdentifier anonymousTeamsUser = new MicrosoftTeamsUserIdentifier(\"<teams-user-id>\")\n    .setAnonymous(true);\n```\n\n### UnknownIdentifier\n\n```java\nimport com.azure.communication.common.UnknownIdentifier;\n\n// For identifiers of unknown type\nUnknownIdentifier unknown = new UnknownIdentifier(\"some-raw-id\");\n```\n\n## Identifier Parsing\n\n```java\nimport com.azure.communication.common.CommunicationIdentifier;\nimport com.azure.communication.common.CommunicationIdentifierModel;\n\n// Parse raw ID to appropriate type\npublic CommunicationIdentifier parseIdentifier(String rawId) {\n    if (rawId.startsWith(\"8:acs:\")) {\n        return new CommunicationUserIdentifier(rawId);\n    } else if (rawId.startsWith(\"4:\")) {\n        String phone = rawId.substring(2);\n        return new PhoneNumberIdentifier(phone);\n    } else if (rawId.startsWith(\"8:orgid:\")) {\n        String teamsId = rawId.substring(8);\n        return new MicrosoftTeamsUserIdentifier(teamsId);\n    } else {\n        return new UnknownIdentifier(rawId);\n    }\n}\n```\n\n## Type Checking Identifiers\n\n```java\nimport com.azure.communication.common.CommunicationIdentifier;\n\npublic void processIdentifier(CommunicationIdentifier identifier) {\n    if (identifier instanceof CommunicationUserIdentifier) {\n        CommunicationUserIdentifier user = (CommunicationUserIdentifier) identifier;\n        System.out.println(\"ACS User: \" + user.getId());\n        \n    } else if (identifier instanceof PhoneNumberIdentifier) {\n        PhoneNumberIdentifier phone = (PhoneNumberIdentifier) identifier;\n        System.out.println(\"Phone: \" + phone.getPhoneNumber());\n        \n    } else if (identifier instanceof MicrosoftTeamsUserIdentifier) {\n        MicrosoftTeamsUserIdentifier teams = (MicrosoftTeamsUserIdentifier) identifier;\n        System.out.println(\"Teams User: \" + teams.getUserId());\n        System.out.println(\"Anonymous: \" + teams.isAnonymous());\n        \n    } else if (identifier instanceof UnknownIdentifier) {\n        UnknownIdentifier unknown = (UnknownIdentifier) identifier;\n        System.out.println(\"Unknown: \" + unknown.getId());\n    }\n}\n```\n\n## Token Access\n\n```java\nimport com.azure.core.credential.AccessToken;\n\n// Get current token (for debugging/logging - don't expose!)\nCommunicationTokenCredential credential = new CommunicationTokenCredential(token);\n\n// Sync access\nAccessToken accessToken = credential.getToken();\nSystem.out.println(\"Token expires: \" + accessToken.getExpiresAt());\n\n// Async access\ncredential.getTokenAsync()\n    .subscribe(token -> {\n        System.out.println(\"Token: \" + token.getToken().substring(0, 20) + \"...\");\n        System.out.println(\"Expires: \" + token.getExpiresAt());\n    });\n```\n\n## Dispose Credential\n\n```java\n// Clean up when done\ncredential.close();\n\n// Or use try-with-resources\ntry (CommunicationTokenCredential cred = new CommunicationTokenCredential(options)) {\n    // Use credential\n    chatClient.doSomething();\n}\n```\n\n## Cloud Environments\n\n```java\nimport com.azure.communication.common.CommunicationCloudEnvironment;\n\n// Available environments\nCommunicationCloudEnvironment publicCloud = CommunicationCloudEnvironment.PUBLIC;\nCommunicationCloudEnvironment govCloud = CommunicationCloudEnvironment.GCCH;\nCommunicationCloudEnvironment dodCloud = CommunicationCloudEnvironment.DOD;\n\n// Set on Teams identifier\nMicrosoftTeamsUserIdentifier teamsUser = new MicrosoftTeamsUserIdentifier(\"<user-id>\")\n    .setCloudEnvironment(CommunicationCloudEnvironment.GCCH);\n```\n\n## Environment Variables\n\n```bash\nAZURE_COMMUNICATION_ENDPOINT=https://<resource>.communication.azure.com\nAZURE_COMMUNICATION_USER_TOKEN=<user-access-token>\n```\n\n## Best Practices\n\n1. **Proactive Refresh** - Always use `setRefreshProactively(true)` for long-lived clients\n2. **Token Security** - Never log or expose full tokens\n3. **Close Credentials** - Dispose of credentials when no longer needed\n4. **Error Handling** - Handle token refresh failures gracefully\n5. **Identifier Types** - Use specific identifier types, not raw strings\n\n## Common Usage Patterns\n\n```java\n// Pattern: Create credential for Chat/Calling client\npublic ChatClient createChatClient(String token, String endpoint) {\n    CommunicationTokenRefreshOptions refreshOptions = \n        new CommunicationTokenRefreshOptions(this::refreshToken)\n            .setRefreshProactively(true)\n            .setInitialToken(token);\n    \n    CommunicationTokenCredential credential = \n        new CommunicationTokenCredential(refreshOptions);\n    \n    return new ChatClientBuilder()\n        .endpoint(endpoint)\n        .credential(credential)\n        .buildClient();\n}\n\nprivate String refreshToken() {\n    // Call your token endpoint\n    return tokenService.getNewToken();\n}\n```\n\n## Trigger Phrases\n\n- \"ACS authentication\", \"communication token credential\"\n- \"user access token\", \"token refresh\"\n- \"CommunicationUserIdentifier\", \"PhoneNumberIdentifier\"\n- \"Azure Communication Services authentication\"\n\n## When to Use\nThis skill is applicable to execute the workflow or actions described in the overview.\n\n## Limitations\n- Use this skill only when the task clearly matches the scope described above.\n- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.\n- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.","tags":["azure","communication","common","java","antigravity","awesome","skills","sickn33","agent-skills","agentic-skills","ai-agent-skills","ai-agents"],"capabilities":["skill","source-sickn33","skill-azure-communication-common-java","topic-agent-skills","topic-agentic-skills","topic-ai-agent-skills","topic-ai-agents","topic-ai-coding","topic-ai-workflows","topic-antigravity","topic-antigravity-skills","topic-claude-code","topic-claude-code-skills","topic-codex-cli","topic-codex-skills"],"categories":["antigravity-awesome-skills"],"synonyms":[],"warnings":[],"endpointUrl":"https://skills.sh/sickn33/antigravity-awesome-skills/azure-communication-common-java","protocol":"skill","transport":"skills-sh","auth":{"type":"none","details":{"cli":"npx skills add sickn33/antigravity-awesome-skills","source_repo":"https://github.com/sickn33/antigravity-awesome-skills","install_from":"skills.sh"}},"qualityScore":"0.700","qualityRationale":"deterministic score 0.70 from registry signals: · indexed on github topic:agent-skills · 34928 github stars · SKILL.md body (9,744 chars)","verified":false,"liveness":"unknown","lastLivenessCheck":null,"agentReviews":{"count":0,"score_avg":null,"cost_usd_avg":null,"success_rate":null,"latency_p50_ms":null,"narrative_summary":null,"summary_updated_at":null},"enrichmentModel":"deterministic:skill-github:v1","enrichmentVersion":1,"enrichedAt":"2026-04-24T18:50:29.477Z","embedding":null,"createdAt":"2026-04-18T21:32:13.971Z","updatedAt":"2026-04-24T18:50:29.477Z","lastSeenAt":"2026-04-24T18:50:29.477Z","tsv":"'+14255551234':299,303,308 '/teamsextension.managecalls':244 '0':504 '1':571 '1.4.0':49 '2':382,583 '20':505 '3':592 '4':307,378,602 '5':610 '8':273,369,390,395 'ac':26,58,67,267,274,370,425,671 'access':469,487,496,677 'accesstoken':488,489 'accesstoken.getexpiresat':494 'across':25 'action':699 'ad':213 'alway':574 'anonym':323,454 'anonymousteamsus':327 'applic':693 'appropri':360 'arrays.aslist':241 'ask':737 'async':177,183,495 'asyncrefresh':187,202 'auth.msft.communication.azure.com':243 'auth.msft.communication.azure.com/teamsextension.managecalls':242 'authent':24,33,55,214,672,686 'automat':62 'avail':197,537 'azur':2,6,28,39,46,212,561,565,683 'azure-communication-common':45 'azure-communication-common-java':1 'bash':560 'best':569 'block':193 'boundari':745 'build':235 'buildclient':119,659 'call':109,135,144,663 'callabl':142,186 'callback':134 'chat':108 'chat/calling':628 'chatclient':111,112,631 'chatclient.dosomething':531 'chatclientbuild':114,654 'check':406 'clarif':739 'class':52 'clean':512 'clear':712 'client':90,126,582,629 'clientid':232 'close':593 'cloud':532 'com.azure':44 'com.azure.communication.common.communicationcloudenvironment':536 'com.azure.communication.common.communicationidentifier':353,410 'com.azure.communication.common.communicationidentifiermodel':355 'com.azure.communication.common.communicationtokencredential':93 'com.azure.communication.common.communicationtokenrefreshoptions':129 'com.azure.communication.common.communicationuseridentifier':263 'com.azure.communication.common.entracommunicationtokencredentialoptions':219 'com.azure.communication.common.microsoftteamsuseridentifier':312 'com.azure.communication.common.phonenumberidentifier':290 'com.azure.communication.common.unknownidentifier':335 'com.azure.core.credential.accesstoken':472 'com.azure.identity.interactivebrowsercredentialbuilder':217 'common':4,9,30,48,620 'communic':3,7,29,40,47,258,562,566,673,684 'communication.azure.com':116,238,564 'communicationcloudenviron':539,542,545 'communicationcloudenvironment.dod':547 'communicationcloudenvironment.gcch':544,557 'communicationcloudenvironment.public':321,541 'communicationidentifi':363,414 'communicationtokencredenti':17,54,84,101,104,172,175,205,208,253,256,481,484,524,527,647,650 'communicationtokenrefreshopt':60,157,160,198,201,637,640 'communicationuseridentifi':65,260,269,272,373,419,420,422,681 'completablefutur':188 'concept':51 'configur':61 'creat':264,625 'createchatcli':632 'cred':525 'credenti':102,117,118,173,206,254,482,510,530,594,597,626,648,657,658,675 'credential.close':516 'credential.gettoken':490 'credential.gettokenasync':497 'criteria':748 'current':474 'currenttoken':168 'data':36 'debugging/logging':477 'describ':700,716 'dispos':509,595 'dodcloud':546 'done':515 'e.164':291 'els':375,387,400,428,440,456 'endpoint':115,563,636,655,656,666 'entra':210 'entracommunicationtokencredentialopt':245,248 'entracredenti':229,249 'entraopt':246,257 'environ':533,538,558,728 'environment-specif':727 'error':603 'etc':110 'execut':695 'expert':733 'expir':141,493,507 'expiri':166 'expos':480,589 'extens':227 'failur':608 'fetcher':185 'fetchnewtokenfromserv':153 'fetchtokenasync':190 'format':292 'fresh':150 'full':590 'futur':189 'future.get':192 'generic':79 'get':148,281,473 'govcloud':543 'grace':609 'handl':604,605 'id':211,277,280,283,348,358 'identifi':19,66,70,75,80,259,265,315,337,349,407,415,417,423,430,436,442,448,458,464,551,611,615 'import':92,128,130,181,216,218,220,222,262,289,311,334,352,354,409,471,535 'initi':170 'input':742 'instal':42 'instanceof':418,431,443,459 'interactivebrowsercredenti':228 'interactivebrowsercredentialbuild':231 'java':5,12,31,91,127,180,215,261,288,310,333,351,408,470,511,534,623 'java.util.arrays':221 'java.util.concurrent.callable':131 'java.util.concurrent.completablefuture':182 'java.util.list':223 'key':50 'limit':704 'list':239 'live':89,125,581 'log':587 'long':124,580 'long-liv':123,579 'longer':600 'match':713 'microsoftteamsuseridentifi':74,309,316,319,326,329,398,444,445,447,552,555 'miss':750 'need':601 'never':586 'new':103,113,159,174,200,207,230,247,255,271,297,318,328,343,372,384,397,402,483,526,554,639,649,653 'number':73,294 'option':169,199,209,528 'orgid':391 'output':722 'overview':703 'pars':350,356 'parseidentifi':364 'pattern':622,624 'permiss':743 'phone':72,226,293,296,380,386,434,438 'phone.getphonenumber':302,439 'phone.getrawid':306 'phonenumb':301 'phonenumberidentifi':69,287,295,298,385,432,433,435,682 'phrase':670 'practic':570 'privat':660 'proactiv':120,155,572 'processidentifi':413 'pstn':71 'public':362,411,630 'publiccloud':540 'purpos':53 'raw':282,347,357,618 'rawid':285,305,366,374,404 'rawid.startswith':368,377,389 'rawid.substring':381,394 'redirecturl':234 'refresh':21,64,98,122,133,156,164,179,573,607,680 'refreshopt':158,176,638,651 'refreshtoken':642,662 'requir':741 'resourc':276,522 'resource-id':275 'resourceendpoint':237,250 'return':152,191,371,383,396,401,652,667 'review':734 'safeti':744 'scope':240,252,715 'secur':585 'server':146 'servic':8,27,41,59,685 'set':548 'setanonym':330 'setcloudenviron':320,556 'setinitialtoken':167,645 'setrefreshproact':162,203,576,643 'setscop':251 'share':23,32 'short':88 'short-liv':87 'simpl':94 'skill':691,707 'skill-azure-communication-common-java' 'some-raw-id':345 'source-sickn33' 'specif':614,729 'static':85,95 'stop':735 'string':99,236,284,300,304,365,379,392,619,633,635,661 'structur':37 'subscrib':498 'substitut':725 'substr':503 'success':747 'sync':486 'system.out.println':424,437,449,453,465,491,500,506 'task':711 'team':76,225,313,324,446,450,550 'teams.getuserid':452 'teams.isanonymous':455 'teamsid':393,399 'teamsus':317,553 'tenantid':233 'test':731 'token':20,63,86,96,121,132,137,151,171,178,184,195,468,475,485,492,499,501,568,584,591,606,634,646,665,674,678,679 'token.getexpiresat':508 'token.gettoken':502 'tokenrefresh':143,161 'tokenservice.getnewtoken':668 'topic-agent-skills' 'topic-agentic-skills' 'topic-ai-agent-skills' 'topic-ai-agents' 'topic-ai-coding' 'topic-ai-workflows' 'topic-antigravity' 'topic-antigravity-skills' 'topic-claude-code' 'topic-claude-code-skills' 'topic-codex-cli' 'topic-codex-skills' 'treat':720 'tri':520,523 'trigger':669 'true':163,204,331,577,644 'try-with-resourc':519 'type':83,340,361,405,612,616 'unknown':82,339,342,462,466 'unknown.getid':467 'unknownidentifi':78,332,341,344,403,460,461,463 'usag':621 'use':13,106,518,529,575,613,689,705 'user':18,56,68,77,268,270,279,314,325,421,426,451,567,676 'user-id':278 'user.getid':286,427 'usertoken':100,105 'util':10,34 'valid':730 'variabl':559 'void':412 'work':15 'workflow':697 'xml':43","prices":[{"id":"45e13153-d2b0-4832-b677-ec72e47ec724","listingId":"570bce0d-14d6-4e1e-b247-5c6d90a1234f","amountUsd":"0","unit":"free","nativeCurrency":null,"nativeAmount":null,"chain":null,"payTo":null,"paymentMethod":"skill-free","isPrimary":true,"details":{"org":"sickn33","category":"antigravity-awesome-skills","install_from":"skills.sh"},"createdAt":"2026-04-18T21:32:13.971Z"}],"sources":[{"listingId":"570bce0d-14d6-4e1e-b247-5c6d90a1234f","source":"github","sourceId":"sickn33/antigravity-awesome-skills/azure-communication-common-java","sourceUrl":"https://github.com/sickn33/antigravity-awesome-skills/tree/main/skills/azure-communication-common-java","isPrimary":false,"firstSeenAt":"2026-04-18T21:32:13.971Z","lastSeenAt":"2026-04-24T18:50:29.477Z"}],"details":{"listingId":"570bce0d-14d6-4e1e-b247-5c6d90a1234f","quickStartSnippet":null,"exampleRequest":null,"exampleResponse":null,"schema":null,"openapiUrl":null,"agentsTxtUrl":null,"citations":[],"useCases":[],"bestFor":[],"notFor":[],"kindDetails":{"org":"sickn33","slug":"azure-communication-common-java","github":{"repo":"sickn33/antigravity-awesome-skills","stars":34928,"topics":["agent-skills","agentic-skills","ai-agent-skills","ai-agents","ai-coding","ai-workflows","antigravity","antigravity-skills","claude-code","claude-code-skills","codex-cli","codex-skills","cursor","cursor-skills","developer-tools","gemini-cli","gemini-skills","kiro","mcp","skill-library"],"license":"mit","html_url":"https://github.com/sickn33/antigravity-awesome-skills","pushed_at":"2026-04-24T06:41:17Z","description":"Installable GitHub library of 1,400+ agentic skills for Claude Code, Cursor, Codex CLI, Gemini CLI, Antigravity, and more. Includes installer CLI, bundles, workflows, and official/community skill collections.","skill_md_sha":"723364eeefa25db066ca0d092556f661b41790f6","skill_md_path":"skills/azure-communication-common-java/SKILL.md","default_branch":"main","skill_tree_url":"https://github.com/sickn33/antigravity-awesome-skills/tree/main/skills/azure-communication-common-java"},"layout":"multi","source":"github","category":"antigravity-awesome-skills","frontmatter":{"name":"azure-communication-common-java","description":"Azure Communication Services common utilities for Java. Use when working with CommunicationTokenCredential, user identifiers, token refresh, or shared authentication across ACS services."},"skills_sh_url":"https://skills.sh/sickn33/antigravity-awesome-skills/azure-communication-common-java"},"updatedAt":"2026-04-24T18:50:29.477Z"}}