2017-05-31 47 views
0

我想從自定義質詢處理程序中使用accessToken。我們希望將該accessToken和令牌ID發送到外部服務。通過調用移動第一個令牌驗證端點來驗證令牌。交替從挑戰處理程序響應獲取訪問令牌WL.Client.getLastAccessToken

如何讀取訪問令牌和令牌ID。在MFP 6.3中,我們有已棄用的WL.Client.getLastAccessToken。是否有API讀取挑戰處理程序收到的訪問令牌?

obtainAccessToken

obtainAccessToken(範圍,的onSuccess,onFailure處) 獲得從工作燈服務器一個OAuth 2.0訪問令牌。該令牌是爲了向使用此Worklight身份驗證方法的外部服務器發送請求所必需的。

參數:

scope - 可選。保護外部資源的安全測試的名稱。如果範圍爲空,則將獲取應用程序默認安全測試的標記。

onSuccess - 成功回調。請注意,不需要解析響應。相反,請使用WL.Client.getLastAccessToken(scope)以獲取最後獲取的令牌。

onFailure - 失敗回調。

推薦使用: 從版本7.0

是否有MobileFirst 7.1

響應數據的任何備用API:{ 「的access_token」:「eyJqcGsiOnsibW9kIjoiQU0wRGQ3eEFkdjZILXlnTDdyOHFDTGRFLTNJMmtrNDV6Z1p0RGRfcXM4ZnZuWWZkaXFUU1Y0XzJ0Nk9HRzhDVjVDZTQxUE1wSXdtTDQxMFg5SVpudmh4b1lpRmNNU2FPZUlxb2UtckpBMHVadXcyckhoWFozV1ZDZUtlelJWY0NPWXNRTi1tUUswbWZ6NV8zby1ldjBVWXdYa1NPd0JCbDFFaHFJd1ZEd09pZWcySk1HbDBFWHNQWmZrTlpJLUhVNG9NaWktVHJOTHpSV2tNbUx2bTA5aEw1em9zVU5BMTV2ZUNLcGgyV3BtU20yUzYxbkRoSDdnTEVveW1EblRFalBZNUFvaDJpbk ktMzZSR1lWTVVVYk80NkNyTlVZdUlvYk9pWGxMekJJaHVJQ3BmVmR4VF94N3N0S1g1QzlCZk1UQjRHa09IUDVjVXY3TnoxZERoSVB1OCIsImV4cCI6IkFRQUIiLCJhbGciOiJSU0EifSwiYWxnIjoiUlMyNTYifQ.eyJpbWYuc2NvcGUiOnsid2x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NlciI6eyJhdXRoQnkiOiJDdXN0b21BdXRoZW50aWNhdG9yUmVhbG0iLCJhdHRyaWJ1dGVzIjoie1wiQXV0aGVudGljYXRpb25EYXRlXCI6XCJNYXkgMzEsIDIwMTcgMjozNzo1MSBQTVwifSIsImlkIjoiZGVtbyJ9LCJpc3MiOiJodHRwOlwvXC9wcmFzYW5uYXMtbWJwLm1ldGxpZmUuY29tOjEwMDgwXC9DdXN0b21BdXRoXC9hdXRob3JpemF0aW9uXC8iLCJleHAiOjE0OTYyNTk0NzEsImlhdCI6MTQ5NjI1NTg3MX0.ojcboxmS-7pQqTx1ebugTuUalbO61_HGmpVSi6_XbIQ_VCknq1zAjRgMeU0NWeaKPHDZiZlEr-nst9EUKzlKvdQNJfDZ-JJF-Nw1IVV0bfy5_YfrDWju3gY5gzNmxi188SydKxDVf6Ncv02YA6SpNU2XaoArrfGnkhmjbEaZUaWj9e8SF9xbMmaNgDfKOQs2WFJZfRY2DdkG 1YodVPipxbtD81Bw4rZ-vroAkXZznd9meWmTZx9bxKtNcMqtala8NFvR6hHiLfKZuZno7FjVv26UV8pfHuLed24fHuMAxhD2wLCKfo6ZDarrcWRVZb30tJZ0AD4mGhnV6Y5PxFO7ng」, 「token_type」: 「承載」, 「expires_in」:3600}

回答

1

對於從6.3遷移到7.1, 請參考ibm.com/support/knowledgecenter/SSHS8R_7.1.0/...,我見您可以使用WLauthorizationManager.getCachedAuthorizationHeader()可在7.1

從7.1到8.0,

請參考這裏備用API對淘汰的API 7.1 https://www.ibm.com/support/knowledgecenter/SSHS8R_8.0.0/com.ibm.worklight.upgrade.doc/devref/c_sdk_changes4migration.html

在T他的特殊場景https://www.ibm.com/support/knowledgecenter/SSHS8R_8.0.0/com.ibm.worklight.apiref.doc/html/refjava-worklight-android-native/html/com/worklight/wlclient/api/WLAuthorizationManager.html必須使用。

您是否嘗試過WLAuthorizationManager.obtainAccessToken(scope)?

+0

嗨Kavitha,謝謝。我們仍然在MobileFirst 7.1而不是8.0。我沒有看到任何MobileFirst 7.1的支持文檔。 – Ragu

+0

Ragu,請參閱https://www.ibm.com/support/knowledgecenter/SSHS8R_7.1.0/com.ibm.worklight.getstart.doc/what_s_new/c_deprecations.html,我看到您可以使用WLauthorizationManager.getCachedAuthorizationHeader( )在7.1 –

+0

可用嗨Kavitha,我試過並得到空。你有沒有工作樣本?謝謝。 – Ragu

相關問題