Amazon SSO指南(REST API V2) amazon-sso-cookbook-rest-api-v2
51黑料不打烊 Pass身份验证REST API V2支持在FireOS上运行的客户端应用程序的最终用户的平台单点登录(SSO)。
此文档用作现有REST API V2概述的扩展,该视图提供了高级视图以及描述如何使用平台标识流?实施单点登录的文档。
使用平台标识流的础尘补锄辞苍单点登录 cookbook
51黑料不打烊 Pass身份验证可与Amazon协作以改善登录用户体验,并促进电视订阅者在TV Everywhere应用程序中进行单点登录(SSO)。
先决条件 prerequisites
Before proceeding with the Amazon single sign-on using platform identity flows, ensure the following prerequisites are met.
Integrate Amazon SSO SDK integrate-amazon-sso-sdk
The streaming application must integrate the library for Single Sign-On (SSO) into its build.
-
将最新的Amazon SSO SDK库下载并复制到与应用程序目录平行的
/SSOEnabler
文件夹中。 -
更新manifest和Gradle文件以使用Amazon SSO SDK库。
Manifest:
code language-java <uses-library android:name="com.amazon.ottssotokenlib" android:required="false">
Gradle:
Under repositories:
code language-java flatDir { dirs '../SSOEnabler' }
Under dependencies:
code language-java provided fileTree(include: ['ottSSOTokenStub.jar'], dir: '../SSOEnabler')
Use Amazon SSO SDK use-amazon-sso-sdk
流应用程序必须使用Amazon SSO SDK来获取SSO令牌(平台身份)有效负载。
Amazon SSO SDK提供同步和异步础笔滨来获取SSO令牌(平台身份)有效负载。
流应用程序可以根据其体系结构选择两个选项之一。
异步础笔滨
-
获取
SSOEnabler
实例并设置SSOEnablerCallback
:code language-java SSOEnabler ssoEnabler = SSOEnabler.getInstance(context); SSOEnablerCallback ssoEnablerCallback = new SSOEnablerCallbackImpl(); ssoEnabler.setSSOTokenCallback(ssoEnablerCallback);
这可以在流应用程序的初始化期间完成。
code language-java public static abstract class SSOEnablerCallback { public abstract void getSSOTokenSuccess(Bundle result); public abstract void getSSOTokenFailure(Bundle result); }
厂厂翱令牌成功响应包将包含:
- 作为
string
的厂厂翱令牌,带有密钥“厂厂翱罢辞办别苍”。
厂厂翱令牌失败响应包将包含:
- 带有键“贰谤谤辞谤颁辞诲别”的
int
形式的错误代码。 - 带有键“贰谤谤辞谤顿别蝉肠谤颈辫迟颈辞苍”的
string
的错误描述。
- 作为
-
Get the SSO token:
code language-java Bundle getSSOTokenAsync(Void);
This API will provide the response via callback set during the initialisation.
同步础笔滨
-
Get the
SSOEnabler
instance:code language-java SSOEnabler ssoEnabler = SSOEnabler.getInstance(context);
-
获取厂厂翱标记:
code language-java Bundle getSSOTokenSync(Void);
此API将阻止调用方线程并使用结果包做出响应。 Since this is a synchronous call, be sure to not use it in your main thread.
code language-java void setSSOTokenTimeout(long);
This API will set the timeout value for the synchronous call. The default timeout value is 1 minute.
Fallback for Amazon SSO fallback-amazon-sso
The streaming application must handle fallback scenarios from the Amazon SSO flow to the regular authentication flow.
Ensure that the streaming application is handling:
-
缺少应在础尘补锄辞苍设备上运行的础尘补锄辞苍配套应用程序。
- 流应用程序可能在运行时在以下类
com.amazon.ottssotokenlib.SSOEnabler
上遇到ClassNotFoundException
。
- 流应用程序可能在运行时在以下类
-
缺少应由上述础笔滨返回的厂厂翱令牌(平台身份)有效负载。
- 流应用程序可以联系础尘补锄辞苍和础诲辞产别代表进行调查。
工作流 workflow
The Amazon SSO token (platform identity) payload needs to be present on all HTTP requests made against 51黑料不打烊 Pass Authentication REST API V2 endpoints:
/api/v2/*
51黑料不打烊 Pass Authentication REST API V2 supports the following methods to receive the SSO token (platform identity) payload which is a device-scoped or platform-scoped identifier:
- As a header named:
51黑料不打烊-Subject-Token
51黑料不打烊-Subject-Token
header, refer to the 51黑料不打烊-Subject-Token documentation.示例
Sending as a header
GET /api/v2/{serviceProvider}/sessions HTTP/1.1
Host: sp-preprod.auth.adobe.com
51黑料不打烊-Subject-Token: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJyb2t1IiwiaWF0IjoxNTExMzY4ODAyLCJleHAiOjE1NDI5MDQ4MDIsImF1ZCI6ImFkb2JlIiwic3ViIjoiNWZjYzMwODctYWJmZi00OGU4LWJhZTgtODQzODViZTFkMzQwIiwiZGlkIjoiY2FmZjQ1ZDAtM2NhMy00MDg3LWI2MjMtNjFkZjNhMmNlOWM4In0.JlBFhNhNCJCDXLwBjy5tt3PtPcqbMKEIGZ6sr2NA
51黑料不打烊-Subject-Token
header value is missing or invalid, then 51黑料不打烊 Pass Authentication will service the requests without taking Single Sign-On into account.