SecuredAuthenticationKey[assoc]
連想 assoc で認証情報と詳細を指定した,安全な認証鍵を表す.
SecuredAuthenticationKey
SecuredAuthenticationKey[assoc]
連想 assoc で認証情報と詳細を指定した,安全な認証鍵を表す.
詳細
- SecuredAuthenticationKeyは,さまざまな接続に低レベルOAuth認証情報を与えるために使われる.
- SecuredAuthenticationKey[assoc]の assoc は,OAuthのバージョンによって要件が異なる.
- SecuredAuthenticationKeyは,接続する際に使われるOAuth認証情報の記号表現である.認証情報は接続が試みられるまでは使われない.
- OAuth 1.0aについては,assoc は以下のキーを持たなければならない.
-
"OAuthVersion" "1.0a" "ConsumerKey" コンシューマーキーまたはアプリケーションクライアントID "ConsumerSecret" コンシューマーシークレットまたはアプリケーションクライアントシークレット "OAuthType" OAuthワークフロータイプ "RequestTokenURL" 一時リクエストトークンのエンドポイント "AccessTokenURL" アクセス許可トークンのエンドポイント - "OAuthType"は次のワークフローをサポートする.
-
"OneLegged" サービスに直接アクセスできるように単一のリクエストに署名する "TwoLegged" サービスにアクセスするためにトークンを取り出して使う "ThreeLegged" ユーザログインを含む,完全なOAuth 1.0a仕様のワークフロー - "AccessTokenURL"および"RequestTokenURL"は次の形式をサポートする.
-
"url" アクセストークンを与えるURL {"url","method"} HTTPメソッド(例:"GET", "POST"等)を指定する - 連想には以下の追加的な項目も与えることができる.
-
"Name" None SecuredAuthenticationKeyの名前 "OAuthToken" None one-legged OAuth 1.0a用のトークン "OAuthTokenSecret" None one-legged OAuth 1.0a用のトークンのシークレット "UserAuthorizationURL" None ユーザ認証のエンドポイント "CallbackURL" Automatic 認証完了後にユーザを送るURL "VerifierInputFunction" Automatic 認証コードを処理する関数 - "CallbackURL"は次の値をサポートする.
-
Automatic Wolframが提供する,OAuth検証器を表示するためのページ Inherited コールバックURLは帯域外(oob)で与えられた "url" カスタムコールバックページのURL - "VerifierInputFunction"は次の値をサポートする.
-
Automatic ダイアログを使ってワークフローを完了するようにユーザを促す "WolframConnectorChannel" Wolframチャネルブローカーを使ってワークフローを完了する - "SignatureMethod"は次の鍵生成とハッシュアルゴリズムのペアをサポートする.
-
{"HMAC","MD2"} 128ビットHMAC-MD2署名 {"HMAC","MD5"} 128ビットHMAC-MD5署名 {"HMAC","SHA1"} 160ビットHMAC-SHA1署名 {"HMAC","SHA256"} 256ビットHMAC-SHA256署名 {"HMAC","SHA384"} 384ビットHMAC-SHA384署名 {"HMAC","SHA512"} 512ビットHMAC-SHA512署名 - "TransmissionMethod"の可能な設定には以下がある.
-
"Headers" すべての認証情報を認証ヘッダーで渡す "Query" すべての認証情報をURLクエリパラメータで渡す - URL["url"]は,"RequestTokenURL","AccessTokenURL","UserAuthorizationURL","CallbackURL"の各フィールドでもサポートされる.
- SecuredAuthenticationKey[assoc]の assoc は以下のキーを持たなければならない.
-
"OAuthVersion" 2.0 "OAuthType" OAuthワークフロータイプ "ClientID" アプリケーションクライアントID "ClientSecret" アプリケーションクライアントシークレット "AccessTokenURL" アクセス許可トークンのエンドポイント - "OAuthType"は次のワークフローをサポートする.
-
"ClientCredentials" クライアントは自らのために動作している "AuthorizationCode" サービスにアクセスするためにトークンを取り出して使う - assoc で以下の追加的なキーも与えることができる.
-
"Name" None SecuredAuthenticationKeyの名前 "RedirectURI" Automatic 認証完了後にユーザを送るURL "Scopes" None OAuth 2.0スコープのリスト "TransmissionMethod" "Headers" ワークフロー中に資格情報がどのように渡されるか "UserAuthorizationURL" None ユーザ認証のエンドポイント "VerifierInputFunction" Automatic 認証コードを処理する関数 - "AccessTokenURL","RequestTokenURL","UserAuthorizationURL"は次の形式をサポートする.
-
"url" アクセストークンを与えるURL {"url","method"} HTTPメソッド(例:"GET", "POST"等)を指定する - "Scopes"は,以下の値をサポートする.
-
None ユーザから追加のパーミッションは要求されない {"scope",…} ユーザがリクエストするパーミッションスコープのリスト {{"scope",…},"scopeDelimiter"} 非標準的な分割文字を使ったパーミッションスコープのリスト - "RedirectURI"は以下の値をサポートする.
-
Automatic Wolframが提供する,OAuth検証器を表示するためのページ "uri" カスタムコールバックページのURI - "VerifierInputFunction"は以下の値をサポートする.
-
Automatic ダイアログを使ってワークフローを完了するようにユーザを促す "WolframConnectorChannel" Wolframチャネルブローカーを使ってワークフローを完了する - "TransmissionMethod"の可能な設定には以下がある.
-
"Headers" すべての認証情報をリクエストのヘッダで渡す "Body" すべての認証情報をリクエスト本体で渡す - URL["url"]は, "AccessTokenURL","UserAuthorizationURL","RedirectURI"の各フィールドでもサポートされる,
OAuth 1.0a
OAuth 2.0
例題
すべて開く すべて閉じる例 (1)
"AuthorizationCode"OAuth 2.0ワークフローを使ってSecuredAuthenticationKeyを作成する:
redditID = "myID";
redditSecret = "mySecret";redditKey = SecuredAuthenticationKey[<|"Name" -> "Reddit", "OAuthType" -> "AuthorizationCode", "OAuthVersion" -> "2.0", "ClientID" -> redditID, "ClientSecret" -> redditSecret, "Scopes" -> {"identity", "edit"}, "AccessTokenURL" -> "https://www.reddit.com/api/v1/access_token", "UserAuthorizationURL" -> "https://www.reddit.com/api/v1/authorize", "VerifierInputFunction" -> "WolframConnectorChannel"|>]URLExecute["https://oauth.reddit.com/api/v1/me", Authentication -> redditKey]//Shortスコープ (13)
基本的な用法 (2)
基本的なSecuredAuthenticationKeyを作成する:
SecuredAuthenticationKey[<|"Name" -> "MyAPI", "OAuthType" -> "AuthorizationCode", "OAuthVersion" -> "2.0", "ClientID" -> "myID", "ClientSecret" -> "mySecret", "AccessTokenURL" -> "https://www.mytestexampleurl.com/api/v1/token", "UserAuthorizationURL" -> "https://www.mytestexampleurl.com/api/v1/authorize"|>]"myParam"のような追加的URLパラメータをURLBuildを使って指定する:
SecuredAuthenticationKey[<|"Name" -> "MyAPI", "OAuthType" -> "AuthorizationCode", "OAuthVersion" -> "2.0", "ClientID" -> "myID", "ClientSecret" -> "mySecret", "AccessTokenURL" -> "https://www.mytestexampleurl.com/api/v1/token", "UserAuthorizationURL" -> URLBuild["https://www.mytestexampleurl.com/api/v1/authorize", {"myParam" -> "myVal"}]|>]OAuth 1.0a (5)
"One-Legged" (1)
OAuthトークンがすでに取得済みの際によく使われる"OneLegged" OAuth 1.0aワークフローを使ってSecuredAuthenticationKeyを作成する:
fatSecretConsumerKey = "myKey";
fatSecretConsumerSecret = "mySecret";fatSecretKeyOneLegged = SecuredAuthenticationKey[<|"ConsumerKey" -> fatSecretConsumerKey,
"ConsumerSecret" -> fatSecretConsumerSecret, "OAuthVersion" -> "1.0a", "OAuthType" -> "OneLegged", "OAuthToken" -> "myToken", "OAuthTokenSecret" -> "mySecret", "SignatureMethod" -> {"HMAC", "SHA1"}, "TransmissionMethod" -> "Query"|>]URLRead[HTTPRequest["https://platform.fatsecret.com/rest/server.api", <|"Query" -> {"method" -> "foods.search", "search_expression" -> "cacao", "format" -> "json"}|>], "Body", Authentication -> fatSecretKeyOneLegged]//ImportString[#, "RawJSON"]&//#[["foods", 1, 1]]&//Dataset"Two-Legged" (1)
"TwoLegged" OAuth 1.0aワークフローを使ってSecuredAuthenticationKeyを作成する:
cloudKey = SecuredAuthenticationKey[<|"Name" -> "WolframCloud SAK",
"RequestTokenURL" -> "https://account.wolfram.com/auth/request-token",
"AccessTokenURL" -> "https://account.wolfram.com/auth/access-token", "OAuthVersion" -> "1.0a", "OAuthType" -> "TwoLegged",
"ConsumerKey" -> "mykey",
"ConsumerSecret" -> "mysecret", "SignatureMethod" -> {"HMAC", "SHA1"},
"TransmissionMethod" -> "Headers", "UUID" -> "b2be6a42-973f-419c-8010-d7bb47d522c2"|>]URLExecute[First@CloudDeploy[APIFunction[{"color" -> "Color"}, Graphics[{#color, Disk[]}, ImageSize -> Small]&, "PNG"], Permissions -> "Private"], {"color" -> "Red"}, Authentication -> cloudKey]"Three-Legged" (3)
"ThreeLegged" OAuth 1.0aワークフローを使ってSecuredAuthenticationKeyを作成する:
fatSecretConsumerKey = "myKey";
fatSecretConsumerSecret = "mySecret";fatSecretKey = SecuredAuthenticationKey[<|"ConsumerKey" -> fatSecretConsumerKey,
"ConsumerSecret" -> fatSecretConsumerSecret, "OAuthVersion" -> "1.0a", "OAuthType" -> "ThreeLegged", "RequestTokenURL" -> {"https://authentication.fatsecret.com/oauth/request_token", "GET"}, "AccessTokenURL" -> {"https://authentication.fatsecret.com/oauth/access_token", "GET"}, "UserAuthorizationURL" -> "https://authentication.fatsecret.com/oauth/authorize", "VerifierInputFunction" -> "WolframConnectorChannel", "SignatureMethod" -> {"HMAC", "SHA1"}, "TransmissionMethod" -> "Query"|>]URLRead[HTTPRequest["https://platform.fatsecret.com/rest/server.api", <|"Query" -> {"method" -> "foods.search", "search_expression" -> "cacao", "format" -> "json"}|>], "Body", Authentication -> fatSecretKey]//ImportString[#, "RawJSON"]&//#[["foods", 1, 1]]&//Datasetfunc = Delayed[HTTPRequestData["Query"]];
customCallbackURL = URL@@CloudDeploy[func, "CustomCallbackURL", Permissions -> "Public"]OAuth 1.0a three-leggedワークフローを使う際に,リダイレクトURIを指定する:
myKey = SecuredAuthenticationKey[<|"Name" -> "MyAuthKey", "OAuthVersion" -> "1.0a",
"OAuthType" -> "ThreeLegged",
"ConsumerKey" -> "myConsumerKey",
"ConsumerSecret" -> "myConsumerSecret",
"RequestTokenURL" -> "https://www.mytestexampleurl.com/services/oauth/request_token",
"AccessTokenURL" -> "https://www.mytestexampleurl.com/services/oauth/access_token",
"UserAuthorizationURL" -> "https://www.mytestexampleurl.com/services/oauth/authorize",
"CallbackURL" -> customCallbackURL,
"SignatureMethod" -> {"HMAC", "SHA1"}|>
]URLExecute["https://api.mytestexampleurl.com/services/rest", {"method" -> "mytestexampleurl.test.login", "api_key" -> myKey}, Authentication -> myKey]サービスとは別にあるいは帯域外でコールバックURLが確立された際に,Inheritedを使ってSecuredAuthenticationKeyを作成する:
SecuredAuthenticationKey[<|"Name" -> "MyAuthKey", "OAuthVersion" -> "1.0a",
"OAuthType" -> "ThreeLegged",
"ConsumerKey" -> "myConsumerKey",
"ConsumerSecret" -> "myConsumerSecret",
"RequestTokenURL" -> "https://api.mytestexampleurl.com/oauth/request_token",
"AccessTokenURL" -> "https://api.mytestexampleurl.com/oauth/access_token",
"UserAuthorizationURL" -> "https://api.mytestexampleurl.com/oauth/authorize",
"CallbackURL" -> Inherited,
"SignatureMethod" -> {"HMAC", "SHA1"}|>]OAuth 2.0 (6)
"AuthorizationCode" (2)
"AuthorizationCode" OAuth 2.0ワークフローを使ってSecuredAuthenticationKeyを作成する:
redditID = "myID";
redditSecret = "mySecret";redditKey = SecuredAuthenticationKey[<|"Name" -> "Reddit", "OAuthType" -> "AuthorizationCode", "OAuthVersion" -> "2.0", "ClientID" -> redditID, "ClientSecret" -> redditSecret, "Scopes" -> {"identity", "edit"}, "AccessTokenURL" -> "https://www.reddit.com/api/v1/access_token", "UserAuthorizationURL" -> "https://www.reddit.com/api/v1/authorize", "VerifierInputFunction" -> "WolframConnectorChannel"|>]URLExecute["https://oauth.reddit.com/api/v1/me", Authentication -> redditKey]//ShortOAuth 2.0認証コードワークフローを使う際に,リダイレクトURIを指定する:
discordConsumerKey = "Discord consumer key";
discordConsumerSecret = "Discord consumer secret";SecuredAuthenticationKey[<|"Name" -> "Discord",
"OAuthType" -> "AuthorizationCode",
"OAuthVersion" -> "2.0", "ClientID" -> discordConsumerKey, "ClientSecret" -> discordConsumerSecret,
"RedirectURI" -> "https://www.wolframcloud.com/objects/forms/oauth/verifier20/",
"AccessTokenURL" -> "https://discord.com/api/oauth2/token",
"UserAuthorizationURL" -> "https://discord.com/api/oauth2/authorize"
|>]"ClientCredentials" (1)
"ClientCredentials" OAuth 2.0ワークフローを使ってSecuredAuthenticationKeyを作成する:
fatSecretClientID = "myKey";
fatSecretClientSecret = "mySecret";SecuredAuthenticationKey[<|"Name" -> "FatSecret", "OAuthType" -> "ClientCredentials", "OAuthVersion" -> "2.0", "ClientID" -> fatSecretClientID, "ClientSecret" -> fatSecretClientSecret, "AccessTokenURL" -> "https://oauth.fatsecret.com/connect/token"|>]"Scopes" (2)
SecuredAuthenticationKey[<|"Name" -> "MyAPI", "OAuthType" -> "AuthorizationCode", "OAuthVersion" -> "2.0", "ClientID" -> "myID", "ClientSecret" -> "mySecret", "AccessTokenURL" -> "https://www.mytestexampleurl.com/api/v1/token", "Scopes" -> {"identity", "edit"}, "UserAuthorizationURL" -> "https://www.mytestexampleurl.com/api/v1/authorize"|>]"+"をデリミタとして使って追加的な"Scopes"を指定する:
SecuredAuthenticationKey[<|"Name" -> "MyAPI", "OAuthType" -> "AuthorizationCode", "OAuthVersion" -> "2.0", "ClientID" -> "myID", "ClientSecret" -> "mySecret", "AccessTokenURL" -> "https://www.mytestexampleurl.com/api/v1/token", "Scopes" -> {{"identity", "edit"}, "+"}, "UserAuthorizationURL" -> "https://www.mytestexampleurl.com/api/v1/authorize"|>]"TransmissionMethod" (1)
デフォルトで,クライアントの資格情報はHTTP認証ヘッダを使って送信される:
SecuredAuthenticationKey[<|"Name" -> "MyAPI", "OAuthType" -> "AuthorizationCode", "OAuthVersion" -> "2.0", "ClientID" -> "myID", "ClientSecret" -> "mySecret", "AccessTokenURL" -> "https://www.mytestexampleurl.com/api/v1/token", "Scopes" -> {{"identity", "edit"}, "+"}, "UserAuthorizationURL" -> "https://www.mytestexampleurl.com/api/v1/authorize"|>]"TransmissionMethod""Body"を使って認証を指定することは,HTTPリクエストの本体の一部として提供されている:
SecuredAuthenticationKey[<|"Name" -> "MyAPI", "OAuthType" -> "AuthorizationCode", "OAuthVersion" -> "2.0", "ClientID" -> "myID", "ClientSecret" -> "mySecret", "AccessTokenURL" -> "https://www.mytestexampleurl.com/api/v1/token", "Scopes" -> {{"identity", "edit"}, "+"}, "UserAuthorizationURL" -> "https://www.mytestexampleurl.com/api/v1/authorize", "TransmissionMethod" -> "Body"|>]関連するガイド
-
▪
- クラウドのパーミッションの制御 ▪
- Webの操作 ▪
- URLの操作 ▪
- HTTPの要求と応答
テキスト
Wolfram Research (2017), SecuredAuthenticationKey, Wolfram言語関数, https://reference.wolfram.com/language/ref/SecuredAuthenticationKey.html (2025年に更新).
CMS
Wolfram Language. 2017. "SecuredAuthenticationKey." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2025. https://reference.wolfram.com/language/ref/SecuredAuthenticationKey.html.
APA
Wolfram Language. (2017). SecuredAuthenticationKey. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/SecuredAuthenticationKey.html
BibTeX
@misc{reference.wolfram_2026_securedauthenticationkey, author="Wolfram Research", title="{SecuredAuthenticationKey}", year="2025", howpublished="\url{https://reference.wolfram.com/language/ref/SecuredAuthenticationKey.html}", note=[Accessed: 04-November-2026]}
BibLaTeX
@online{reference.wolfram_2026_securedauthenticationkey, organization={Wolfram Research}, title={SecuredAuthenticationKey}, year={2025}, url={https://reference.wolfram.com/language/ref/SecuredAuthenticationKey.html}, note=[Accessed: 04-November-2026]}