交替从质询处理程序响应中获取访问令牌 WL.Client.getLastAccessToken
Alternate to get access token from challenge handler response WL.Client.getLastAccessToken
我正在尝试使用来自自定义质询处理程序的 accessToken。我们想将该 accessToken 和令牌 ID 发送到外部服务。将通过调用移动优先令牌验证端点来验证令牌。
如何读取访问令牌和令牌 ID。在 MFP 6.3 中,我们有 WL.Client.getLastAccessToken 已被弃用。是否有任何 API 读取为质询处理程序收到的访问令牌。
获取AccessToken
obtainAccessToken(范围,onSuccess,onFailure)
从 Worklight 服务器获取 OAuth 2.0 访问令牌。需要令牌才能向使用此 Worklight 身份验证方法的外部服务器发送请求。
参数:
scope - 可选。保护外部资源的安全测试的名称。如果scope为null,则获取应用默认安全测试的token。
onSuccess - 成功回调。请注意,无需解析响应。相反,使用 WL.Client.getLastAccessToken(scope) 以获得最后获得的令牌。
onFailure - 失败回调。
已弃用:
从 7.0 版本开始
MobileFirst 7.1
有没有替代品API
响应数据:{"access_token":"eyJqcGsiOnsibW9kIjoiQU0wRGQ3eEFkdjZILXlnTDdyOHFDTGRFLTNJMmtrNDV6Z1p0RGRfcXM4ZnZuWWZkaXFUU1Y0XzJ0Nk9HRzhDVjVDZTQxUE1wSXdtTDQxMFg5SVpudmh4b1lpRmNNU2FPZUlxb2UtckpBMHVadXcyckhoWFozV1ZDZUtlelJWY0NPWXNRTi1tUUswbWZ6NV8zby1ldjBVWXdYa1NPd0JCbDFFaHFJd1ZEd09pZWcySk1HbDBFWHNQWmZrTlpJLUhVNG9NaWktVHJOTHpSV2tNbUx2bTA5aEw1em9zVU5BMTV2ZUNLcGgyV3BtU20yUzYxbkRoSDdnTEVveW1EblRFalBZNUFvaDJpbkktMzZSR1lWTVVVYk80NkNyTlVZdUlvYk9pWGxMekJJaHVJQ3BmVmR4VF94N3N0S1g1QzlCZk1UQjRHa09IUDVjVXY3TnoxZERoSVB1OCIsImV4cCI6IkFRQUIiLCJhbGciOiJSU0EifSwiYWxnIjoiUlMyNTYifQ.eyJpbWYuc2NvcGUiOn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hdXRoQnkiOiJDdXN0b21BdXRoZW50aWNhdG9yUmVhbG0iLCJhdHRyaWJ1dGVzIjoie1wiQXV0aGVudGljYXRpb25EYXRlXCI6XCJNYXkgMzEsIDIwMTcgMjozNzo1MSBQTVwifSIsImlkIjoiZGVtbyJ9LCJpc3MiOiJodHRwOlwvXC9wcmFzYW5uYXMtbWJwLm1ldGxpZmUuY29tOjEwMDgwXC9DdXN0b21BdXRoXC9hdXRob3JpemF0aW9uXC8iLCJleHAiOjE0OTYyNTk0NzEsImlhdCI6MTQ5NjI1NTg3MX0.ojcboxmS-7pQqTx1ebugTuUalbO61_HGmpVSi6_XbIQ_VCknq1zAjRgMeU0NWeaKPHDZiZlEr-nst9EUKzlKvdQNJfDZ-jjF-Nw1IVV0bfy5_YfrDWju3gY5gzNmxi188SydKxDVf6Ncv02YA6SpNU2XaoArrfGnkhmjbEaZUaWj9e8SF9xbMmaNgDfKOQs2WFJZfRY2DdkG1YodVPipxbtD81Bw4rZ-vroAkXZznd9meWmTZx9bxKtNcMqtala8NFvR6hHiLfKZuZno7FjVv26UV8pfHuLed24fHuMAxhD2wLCKfo6ZDarrcWRVZb30tJZ0AD4mGhnV6Y5PxFO7ng","token_type" :"bearer","expires_in":3600}
对于从 6.3 迁移到 7.1,
请参考 ibm.com/support/knowledgecenter/SSHS8R_7.1.0/… ,我看到您可以使用 7.1
中可用的 WLauthorizationManager.getCachedAuthorizationHeader()
从 7.1 到 8.0,
请参考此处 Alternate API's for deprecated APIs in 7.1 https://www.ibm.com/support/knowledgecenter/SSHS8R_8.0.0/com.ibm.worklight.upgrade.doc/devref/c_sdk_changes4migration.html
你试过WLAuthorizationManager.obtainAccessToken(范围)吗?
我正在尝试使用来自自定义质询处理程序的 accessToken。我们想将该 accessToken 和令牌 ID 发送到外部服务。将通过调用移动优先令牌验证端点来验证令牌。
如何读取访问令牌和令牌 ID。在 MFP 6.3 中,我们有 WL.Client.getLastAccessToken 已被弃用。是否有任何 API 读取为质询处理程序收到的访问令牌。
获取AccessToken
obtainAccessToken(范围,onSuccess,onFailure) 从 Worklight 服务器获取 OAuth 2.0 访问令牌。需要令牌才能向使用此 Worklight 身份验证方法的外部服务器发送请求。
参数:
scope - 可选。保护外部资源的安全测试的名称。如果scope为null,则获取应用默认安全测试的token。
onSuccess - 成功回调。请注意,无需解析响应。相反,使用 WL.Client.getLastAccessToken(scope) 以获得最后获得的令牌。
onFailure - 失败回调。
已弃用: 从 7.0 版本开始
MobileFirst 7.1
有没有替代品API响应数据:{"access_token":"eyJqcGsiOnsibW9kIjoiQU0wRGQ3eEFkdjZILXlnTDdyOHFDTGRFLTNJMmtrNDV6Z1p0RGRfcXM4ZnZuWWZkaXFUU1Y0XzJ0Nk9HRzhDVjVDZTQxUE1wSXdtTDQxMFg5SVpudmh4b1lpRmNNU2FPZUlxb2UtckpBMHVadXcyckhoWFozV1ZDZUtlelJWY0NPWXNRTi1tUUswbWZ6NV8zby1ldjBVWXdYa1NPd0JCbDFFaHFJd1ZEd09pZWcySk1HbDBFWHNQWmZrTlpJLUhVNG9NaWktVHJOTHpSV2tNbUx2bTA5aEw1em9zVU5BMTV2ZUNLcGgyV3BtU20yUzYxbkRoSDdnTEVveW1EblRFalBZNUFvaDJpbkktMzZSR1lWTVVVYk80NkNyTlVZdUlvYk9pWGxMekJJaHVJQ3BmVmR4VF94N3N0S1g1QzlCZk1UQjRHa09IUDVjVXY3TnoxZERoSVB1OCIsImV4cCI6IkFRQUIiLCJhbGciOiJSU0EifSwiYWxnIjoiUlMyNTYifQ.eyJpbWYuc2NvcGUiOnsid2xfYW50aVhTUkZSZWFsbSI6eyJleHAiOjE0OTYyNTk0NzEsIm1hbmRhdG9yeSI6dHJ1ZX0sIkN1c3RvbUF1dGhlbnRpY2F0b3JSZWFsbSI6eyJleHAiOjE0OTYyNTk0NzF9LCJ3bF9kaXJlY3RVcGRhdGVSZWFsbSI6eyJleHAiOjE0OTYyNTk0NzAsIm1hbmRhdG9yeSI6dHJ1ZX0sIndsX3JlbW90ZURpc2FibGVSZWFsbSI6eyJleHAiOjE0OTYyNTYxNzAsIm1hbmRhdG9yeSI6dHJ1ZX0sIndsX2RldmljZU5vUHJvdmlzaW9uaW5nUmVhbG0iOnsiZXhwIjoxNDk2MjU5NDcxLCJtYW5kYXRvcnkiOnRydWV9LCJ3bF9hbm9ueW1vdXNVc2VyUmVhbG0iOnsiZXhwIjoxNDk2MjU5NDcwLCJtYW5kYXRvcnkiOnRydWV9fSwiaXNzIjoiaHR0cDpcL1wvcHJhc2FubmFzLW1icC5tZXRsaWZlLmNvbToxMDA4MFwvQ3VzdG9tQXV0aFwvYXV0aG9yaXphdGlvblwvIiwiZXhwIjoxNDk2MjU5NDcxLCJwcm4iOiI0ODE4YTJkODNkMDE0ZDkxNzcwNTdmOTc3MGI1OThkOTA5NmUxZmI3In0.qiej5KRanOOx_sjdCgdl8cFVLC88_V1yIcAML2GetHEjH8-ORyabJ0Ax0kjgEU5tMgEh6wg7A0LeW9rcZR_A9K5biLEQRJBvqcjKzedmq9DFYB_GluRL0W7pDyOk2ZpRBKQm5FXsxjKKda-yVd_7i7ipfYjMqUWctcloeXelDkPxbfxVxB1X7lyqmihflvE3ir9UG7WkxxbEAtZIUIdMkmmwCoitlTTjKPLjHfihlEJQQEm59jgXuBv2l62nWVG9eoqNnTCuYH3PlpiDK1YyK0ThBZxjAa2pLkOH1myPQRH2e-rfwJlaOit5ZosEm7pwXM2AEnvKNYyhw_2RPAnLVA","scope":"wl_antiXSRFRealm CustomAuthenticatorRealm wl_directUpdateRealm wl_remoteDisableRealm wl_deviceNoProvisioningRealm wl_anonymousUserRealm","id_token":"eyJqcGsiOnsibW9kIjoiQU0wRGQ3eEFkdjZILXlnTDdyOHFDTGRFLTNJMmtrNDV6Z1p0RGRfcXM4ZnZuWWZkaXFUU1Y0XzJ0Nk9HRzhDVjVDZTQxUE1wSXdtTDQxMFg5SVpudmh4b1lpRmNNU2FPZUlxb2UtckpBMHVadXcyckhoWFozV1ZDZUtlelJ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dXRoXC9hdXRob3JpemF0aW9uXC8iLCJleHAiOjE0OTYyNTk0NzEsImlhdCI6MTQ5NjI1NTg3MX0.ojcboxmS-7pQqTx1ebugTuUalbO61_HGmpVSi6_XbIQ_VCknq1zAjRgMeU0NWeaKPHDZiZlEr-nst9EUKzlKvdQNJfDZ-jjF-Nw1IVV0bfy5_YfrDWju3gY5gzNmxi188SydKxDVf6Ncv02YA6SpNU2XaoArrfGnkhmjbEaZUaWj9e8SF9xbMmaNgDfKOQs2WFJZfRY2DdkG1YodVPipxbtD81Bw4rZ-vroAkXZznd9meWmTZx9bxKtNcMqtala8NFvR6hHiLfKZuZno7FjVv26UV8pfHuLed24fHuMAxhD2wLCKfo6ZDarrcWRVZb30tJZ0AD4mGhnV6Y5PxFO7ng","token_type" :"bearer","expires_in":3600}
对于从 6.3 迁移到 7.1, 请参考 ibm.com/support/knowledgecenter/SSHS8R_7.1.0/… ,我看到您可以使用 7.1
中可用的 WLauthorizationManager.getCachedAuthorizationHeader()从 7.1 到 8.0,
请参考此处 Alternate API's for deprecated APIs in 7.1 https://www.ibm.com/support/knowledgecenter/SSHS8R_8.0.0/com.ibm.worklight.upgrade.doc/devref/c_sdk_changes4migration.html
你试过WLAuthorizationManager.obtainAccessToken(范围)吗?