Chuyển đến nội dung
Skillpedia
Email và tin nhắn48k · #3912

azure-communication-common-java

Skill này làm gì

Công cụ này giúp lập trình viên quản lý xác thực và nhận diện người dùng trong các dịch vụ liên lạc của Microsoft Azure. Nó đơn giản hóa việc kết nối an toàn và nhận diện các loại người dùng khác nhau, như người dùng Azure Communication Services, số điện thoại và người dùng Microsoft Teams.

Khi nào nên dùng

  • ✓Khi bạn thiết lập xác thực cho một ứng dụng liên lạc mới.
  • ✓Khi bạn cần nhận diện một người dùng cụ thể trong cuộc gọi hoặc chat.
  • ✓Khi bạn triển khai tự động làm mới access token để duy trì kết nối đang hoạt động.

Liên kết skill

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/azure-communication-common-java/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/azure-communication-common-java/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Làm thế nào để thiết lập xác thực cho người dùng Azure Communication Services bằng token?”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Nó cung cấp các đoạn mã sẵn sàng dùng để lập trình viên xác thực người dùng. Điều này bao gồm tạo các đối tượng đại diện cho người dùng và cấu hình cách quản lý access token, kể cả làm mới tự động.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

Azure Communication Common (Java)

Shared authentication utilities and data structures for Azure Communication Services.

Installation

<dependency>
    <groupId>com.azure</groupId>
    <artifactId>azure-communication-common</artifactId>
    <version>1.4.0</version>
</dependency>

Key Concepts

Class Purpose
CommunicationTokenCredential Authenticate users with ACS services
CommunicationTokenRefreshOptions Configure automatic token refresh
CommunicationUserIdentifier Identify ACS users
PhoneNumberIdentifier Identify PSTN phone numbers
MicrosoftTeamsUserIdentifier Identify Teams users
UnknownIdentifier Generic identifier for unknown types

CommunicationTokenCredential

Static Token (Short-lived Clients)

import com.azure.communication.common.CommunicationTokenCredential;

// Simple static token - no refresh
String userToken = "<user-access-token>";
CommunicationTokenCredential credential = new CommunicationTokenCredential(userToken);

// Use with Chat, Calling, etc.
ChatClient chatClient = new ChatClientBuilder()
    .endpoint("https://<resource>.communication.azure.com")
    .credential(credential)
    .buildClient();

Proactive Token Refresh (Long-lived Clients)

import com.azure.communication.common.CommunicationTokenRefreshOptions;
import java.util.concurrent.Callable;

// Token refresher callback - called when token is about to expire
Callable<String> tokenRefresher = () -> {
    // Call your server to get a fresh token
    return fetchNewTokenFromServer();
};

// With proactive refresh
CommunicationTokenRefreshOptions refreshOptions = new CommunicationTokenRefreshOptions(tokenRefresher)
    .setRefreshProactively(true)      // Refresh before expiry
    .setInitialToken(currentToken);    // Optional initial token

CommunicationTokenCredential credential = new CommunicationTokenCredential(refreshOptions);

Async Token Refresh

import java.util.concurrent.CompletableFuture;

// Async token fetcher
Callable<String> asyncRefresher = () -> {
    CompletableFuture<String> future = fetchTokenAsync();
    return future.get();  // Block until token is available
};

CommunicationTokenRefreshOptions options = new CommunicationTokenRefreshOptions(asyncRefresher)
    .setRefreshProactively(true);

CommunicationTokenCredential credential = new CommunicationTokenCredential(options);

Entra ID (Azure AD) Authentication

import com.azure.identity.InteractiveBrowserCredentialBuilder;
import com.azure.communication.common.EntraCommunicationTokenCredentialOptions;
import java.util.Arrays;
import java.util.List;

// For Teams Phone Extensibility
InteractiveBrowserCredential entraCredential = new InteractiveBrowserCredentialBuilder()
    .clientId("<your-client-id>")
    .tenantId("<your-tenant-id>")
    .redirectUrl("<your-redirect-uri>")
    .build();

String resourceEndpoint = "https://<resource>.communication.azure.com";
List<String> scopes = Arrays.asList(
    "https://auth.msft.communication.azure.com/TeamsExtension.ManageCalls"
);

EntraCommunicationTokenCredentialOptions entraOptions = 
    new EntraCommunicationTokenCredentialOptions(entraCredential, resourceEndpoint)
        .setScopes(scopes);

CommunicationTokenCredential credential = new CommunicationTokenCredential(entraOptions);

Communication Identifiers

CommunicationUserIdentifier

import com.azure.communication.common.CommunicationUserIdentifier;

// Create identifier for ACS user
CommunicationUserIdentifier user = new CommunicationUserIdentifier("8:acs:resource-id_user-id");

// Get raw ID
String rawId = user.getId();

PhoneNumberIdentifier

import com.azure.communication.common.PhoneNumberIdentifier;

// E.164 format phone number
PhoneNumberIdentifier phone = new PhoneNumberIdentifier("+14255551234");

String phoneNumber = phone.getPhoneNumber();  // "+14255551234"
String rawId = phone.getRawId();              // "4:+14255551234"

MicrosoftTeamsUserIdentifier

import com.azure.communication.common.MicrosoftTeamsUserIdentifier;

// Teams user identifier
MicrosoftTeamsUserIdentifier teamsUser = new MicrosoftTeamsUserIdentifier("<teams-user-id>")
    .setCloudEnvironment(CommunicationCloudEnvironment.PUBLIC);

// For anonymous Teams users
MicrosoftTeamsUserIdentifier anonymousTeamsUser = new MicrosoftTeamsUserIdentifier("<teams-user-id>")
    .setAnonymous(true);

…
Câu hỏi thường gặp

“Identifiers” là gì?

Đó là cách biểu diễn và phân biệt các loại người dùng hoặc số điện thoại khác nhau trong các dịch vụ liên lạc.

“Token” là gì?

Đó là một khóa tạm thời cho phép người dùng truy cập an toàn vào dịch vụ liên lạc.

Hệ thống xử lý token hết hạn như thế nào?

Nó có thể được cấu hình để tự động làm mới token trước khi hết hạn, đảm bảo kết nối của người dùng không bị gián đoạn.

Chi tiết

Mô tả gốc của tác giả

Azure Communication Services common utilities for Java. Use when working with CommunicationTokenCredential, user identifiers, token refresh, or shared authentication across ACS services.

repo: sickn33/agentic-awesome-skills

Độ phổ biến

Sao GitHub
48k
Vị trí xếp hạng
#3912
Giấy phép
MIT
Cập nhật
15/10/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự