我開始使用Azure-Samples/active-directory-b2c-ios-swift-native-msal應用程序來演示Azure B2C租戶的功能。我已經完成了刷新令牌功能之外的所有工作。我已添加「offline_access」作用域以確保提供了刷新令牌。Azure B2C刷新令牌功能不適用於iOS Swift示例應用程序
,我得到的第一個錯誤:
let application = try MSALPublicClientApplication.init(clientId: kClientID, authority: kAuthority)
let thisUser = try self.getUserByPolicy(withUsers: application.users(), forPolicy: kSignupOrSigninPolicy)
application.acquireTokenSilent(forScopes: kScopes, user: thisUser) { (result, error) in
if error == nil {
self.accessToken = (result?.accessToken)!
self.loggingText.text = "Refreshing token silently"
self.loggingText.text = "Refreshed Access token is \(self.accessToken)"
}
於是,我就在MSAL用戶從最初的授權存儲,並通過它進入AcquireTokenSilent方法。
我得到這個錯誤:
Failed to find any access token error
let application = try MSALPublicClientApplication.init(clientId: kClientID, authority: kAuthority)
let thisUser = userFromAuth
application.acquireTokenSilent(forScopes: kScopes, user: thisUser) { (result, error) in
if error == nil {
self.accessToken = (result?.accessToken)!
self.loggingText.text = "Refreshing token silently"
self.loggingText.text = "Refreshed Access token is \(self.accessToken)"
}
最後,我嘗試添加在註冊/簽到(初始AUTH調用)到AcquireTokenSilent使用權限/政策和我得到這個錯誤:
我得到:「沒有與在緩存中找到的參數相匹配的令牌。」 (不會讓我發佈第三鏈接)
let application = try MSALPublicClientApplication.init(clientId: kClientID, authority: kAuthority)
let thisUser = userFromAuth
application.acquireTokenSilent(forScopes: kScopes, user: thisUser, authority: kAuthority) { (result, error) in
if error == nil {
self.accessToken = (result?.accessToken)!
self.loggingText.text = "Refreshing token silently"
self.loggingText.text = "Refreshed Access token is \(self.accessToken)"
}
我已經在Android示例應用程序測試的刷新令牌功能,我能夠刷新令牌成功,所以我不認爲這個問題是在任何地方我們的B2C。我還讀到MSAL庫處理刷新不同於Android和Obj-C示例中使用的AppAuth庫,因此我不確定是否有某些我丟失的東西。
任何洞察什麼是錯的將是偉大的!
添加屏幕截圖不會讓我在問題中發帖:[第三個錯誤屏幕截圖。](http://imgur.com/YgNluPc) –
你能在解答框中發佈你的決議嗎(這樣我們可以確保這個問題已經得到解答,我可以贊成它) – Parakh