![]() |
|
![]() |
|
![]() |
|
![]() |
|
![]() |
|
![]() |
|
![]() |
|
![]() |
|
![]() |
|
![]() |
|
![]() |
|
![]() |
|
![]() |
|
![]() |
|
![]() |
|
2024年、ARCGISは.NETチーム向けのSDKをマップしました。
In 2024, the ArcGIS Maps SDK for .NET team introduced significant changes to authentication APIs as part of a long-term effort to simplify and align the .NET Maps SDK with other Native Maps SDKs. This transition also involved deprecating older APIs to streamline development and maintain compatibility with the broader ArcGIS Platform.
2024年、ARCGISは.NETチーム向けのSDKをマップし、.NETマップSDKを他のネイティブマップSDKと簡素化および整列させるための長期的な取り組みの一環として、認証APIに大幅な変更を導入しました。この遷移には、開発を合理化し、より広範なArcGISプラットフォームとの互換性を維持するために、古いAPIを非難することも含まれます。
This blog post will guide you through this transition, highlighting new capabilities, outlining clear paths from deprecated APIs, and providing practical code examples to help you implement these changes quickly and confidently.
このブログ投稿では、この移行をガイドし、新しい機能を強調し、非推奨APIからの明確なパスの概要を説明し、これらの変更を迅速かつ自信を持って実装するのに役立つ実用的なコード例を提供します。
New Credential Types
新しい資格情報タイプ
Let’s start by exploring the new credential types that form the foundation of the updated authentication system.
まず、更新された認証システムの基礎を形成する新しい資格型タイプを調査しましょう。
OAuthUserCredential (200.6+)
oauthusercredential(200.6+)
This replaces OAuthTokenCredentials of type OAuthAuthorizationCode.
これにより、タイプのoauthauthorizationcodeのoauthtokencedentialsが置き換えられます。
OAuthUserCredential implements user authentication using OAuth “authorization code” flow with PKCE. This is the recommended approach for authenticating end users, providing extra security compared to other methods.
oauthusercredentialは、PKCEを使用したOAuthの「承認コード」フローを使用してユーザー認証を実装します。これは、エンドユーザーを認証するための推奨アプローチであり、他の方法と比較して追加のセキュリティを提供します。
When a user signs in to your application with their ArcGIS account, a token is generated that authorizes your app to access services and content on behalf of the user. The available resources and functionality depend on the user’s ArcGIS account type, roles, and privileges.
ユーザーがARCGISアカウントでアプリケーションにサインインすると、ユーザーに代わってサービスとコンテンツにアクセスすることをアプリに許可するトークンが生成されます。利用可能なリソースと機能は、ユーザーのARCGISアカウントの種類、役割、特権に依存します。
To implement this authentication flow, you need to:
この認証フローを実装するには、次のことが必要です。
Our Access services with OAuth credentials tutorial provides a complete implementation example.
OAUTH資格情報のチュートリアルを備えたアクセスサービスは、完全な実装の例を提供します。
OAuthAppCredential (200.5+)
oauthappcredential(200.5+)
This replaces OAuthTokenCredentials of type OAuthClientCredentials.
これにより、型oauthclientcredentialsのoauthtokencedentialsが置き換えられます。
OAuthApplicationCredential implements app authentication using OAuth “client credentials” flow. Use this to create applications that do not require users to sign in, but still need access to token-secured resources and services.
OAUTHAPPLICATIONCREDENTIALは、OAUTH「クライアント資格情報」フローを使用してアプリ認証を実装します。これを使用して、ユーザーにサインインする必要のないアプリケーションを作成しますが、トークンが配置されたリソースとサービスにアクセスする必要があります。
With this approach, requests are made using the credits and privileges associated with your app’s account rather than an individual user’s account. An app credential is created from a client ID and client secret that have been pre-registered with the portal.
このアプローチを使用すると、個々のユーザーのアカウントではなく、アプリのアカウントに関連付けられたクレジットと特権を使用してリクエストが行われます。アプリの資格情報は、ポータルで事前に登録されたクライアントIDおよびクライアントシークレットから作成されます。
The client secret should be treated as confidential information since it allows direct billing to your developer account. This authentication method is intended for secure environments where credentials cannot be easily exposed to end users. Never include your client secret in publicly distributed applications.
クライアントの秘密は、開発者アカウントへの直接請求を許可するため、機密情報として扱われるべきです。この認証方法は、資格情報をエンドユーザーに簡単に公開できない安全な環境を対象としています。公開されているアプリケーションにクライアントの秘密を決して含めないでください。
AccessTokenCredential (200.6+)
AccessTokEncredential(200.6+)
This replaces ArcGISTokenCredentials created by GenerateCredentialAsync.
これは、GenerateCredentionAsyncによって作成されたArcgistokencredentionsに取って代わります。
AccessTokenCredential provides an access token for secured ArcGIS content and services. You can obtain this token in several ways:
AccessTokenCredentialは、保護されたArcGISコンテンツとサービスのアクセストークンを提供します。このトークンをいくつかの方法で入手できます。
Our ArcGIS token challenge sample shows how to create this credential in response to an authentication challenge. You can also create and add a credential to the AuthenticationManager before accessing secured services.
ARCGISトークンチャレンジサンプルは、認証チャレンジに応じてこの資格情報を作成する方法を示しています。また、Secured Servicesにアクセスする前に、AuthenticationManagerに資格情報を作成して追加することもできます。
PregeneratedTokenCredential (200.5+)
プレジェネレーショントークレディション(200.5+)
This replaces ArcGISTokenCredentials created by the token-string constructor.
これは、トークンストリングコンストラクターによって作成されたArcgistokencedentialsに取って代わります。
PregeneratedTokenCredential accesses token-secured ArcGIS content and services using an independently generated token. This credential type gives you flexibility when integrating with custom authentication systems. Use it when you:
Pre GeneratedTokencedentialは、独立して生成されたトークンを使用して、トークンが配置されたArcGISコンテンツとサービスにアクセスします。この資格情報タイプは、カスタム認証システムと統合する際の柔軟性を提供します。あなたがそれを使用するとき:
New Supporting APIs
新しいサポートAPI
Beyond the credential types themselves, several supporting APIs have been added to enhance flexibility and control.
資格情報自体を超えて、柔軟性と制御を強化するために、いくつかのサポートAPIが追加されています。
Server Certificate Validation (200.6+)
サーバー証明書の検証(200.6+)
When working with HTTPS services, you can now customize how SSL/TLS certificates are validated. Specify a custom callback when configuring HTTP settings to examine all SSL connections made by the Maps SDK.
HTTPSサービスを操作するとき、SSL/TLS証明書の検証方法をカスタマイズできるようになりました。 HTTP設定を構成するときにカスタムコールバックを指定して、Maps SDKによって作成されたすべてのSSL接続を調べます。
Server certificates are usually validated by the operating system using default policies and known Certificate Authorities, but your own validator can accept or reject connections based on custom criteria. For example:
サーバー証明書は通常、デフォルトのポリシーと既知の証明書当局を使用してオペレーティングシステムによって検証されますが、独自のバリデーターはカスタム基準に基づいて接続を受け入れるか拒否できます。例えば:
The callback uses the standard .NET RemoteCertificateValidationCallback signature. For more information including code examples, see Microsoft’s guide to custom X509Certificate validation.
コールバックは、標準の.NET RemoteCertificateValidationCallback署名を使用します。コードの例を含む詳細については、MicrosoftのカスタムX509Certificateの検証ガイドを参照してください。
IHttpMessageInterceptor (200.5+)
ihttpmessageInterceptor(200.5+)
The new IHttpMessageInterceptor interface allows you to monitor, modify, or even mock HTTP requests and responses. This powerful capability can be configured globally when configuring HTTP settings on startup. Common use cases include:
新しいIHTTPMESSAGEINTERCEPTORインターフェイスを使用すると、HTTPのリクエストと応答を監視、変更、またはモックすることさえできます。この強力な機能は、起動時にHTTP設定を構成するときにグローバルに構成できます。一般的なユースケースは次のとおりです。
Logging and Diagnostics: Log request and response details for monitoring and debugging:
ロギングと診断:監視とデバッグのためのログ要求と応答の詳細:
import logging
ロギングをインポートします
logger = logging.getLogger(__name__)
logger = logging.getLogger(__ name__)
class MessageInterceptor(IHttpMessageInterceptor):
class messageInterceptor(ihttpmessageInterceptor):
"""Logs request and response details to the console."""
"" "ログ要求とコンソールへの応答の詳細。" ""
def OnRequest(self, request, cancellationToken):
def onrequest(self、request、cancellationtoken):
"""Called before a request is sent."""
"" "リクエストが送信される前に呼び出されました。" ""
logger.info(f"Request: {request.Method} {request.RequestUri}")
logger.info(f "request:{request.method} {request.requesturi}")
for header in request.Headers:
request.headersのヘッダーの場合:
logger.info(f" Header: {header}")
logger.info(f "header:{header}")
async def main():
async def main():
"""Main function to configure and run the message interceptor."""
"" "メッセージインターセプターを構成して実行するメイン関数" ""
message_interceptor = MessageInterceptor()
message_interceptor = messageinterceptor()
http_settings = HttpSettings.Builder().AddMessageInterceptor(message_interceptor).Build()
http_settings = httpsettings.builder()。addmessageInterceptor(message_interceptor).build()
async with AuthenticationManager.CreateInstanceAsync(credentials, http_settings) as auth_manager:
authicationmanager.createinstanceasync(credentials、http_settings)をauth_manager with async:
user = await ArcGISUser.CurrentUserAsync(auth_manager)
user = wait arcgisuser.currentuserasync(auth_manager)
logger.info(f"Logged in as: {user.Username}")
logger.info(f "as:{user.username}")のログイン ")
if __name__ == "__main__":
__name__ == "__main__"の場合:
logging.basicConfig(level=logging.INFO, format='%(asctime
logging.basicconfig(level = logging.info、format = '%(asctime)
免責事項:info@kdj.com
提供される情報は取引に関するアドバイスではありません。 kdj.com は、この記事で提供される情報に基づいて行われた投資に対して一切の責任を負いません。暗号通貨は変動性が高いため、十分な調査を行った上で慎重に投資することを強くお勧めします。
このウェブサイトで使用されているコンテンツが著作権を侵害していると思われる場合は、直ちに当社 (info@kdj.com) までご連絡ください。速やかに削除させていただきます。