我正在使用 iOS ADAL 库版本 2.2.6 并在成功登录后接收刷新令牌。现在我想使用这个刷新令牌进行静默呼叫。我尝试使用以下方法,但无法返回访问令牌。
ADAuthenticationContext *authContext;
[authContext acquireTokenSilentWithResource:resourceId
clientId:clientId
redirectUri:redirectUri
userId:strUserID //loggedIn userID
completionBlock:^(ADAuthenticationResult *result){
// It alway throws an error //Please call the non-silent acquireTokenWithResource methods.
if(result.error){
ADAuthenticationError *error = nil;
authContext = [ADAuthenticationContext authenticationContextWithAuthority:inputData.authority error:&error];
[authContext acquireTokenWithResource:inputData.ResourceID
clientId:inputData.ClientId // Comes from App Portal
redirectUri:inputData.RedirectUri // Comes from App Portal
completionBlock:^(ADAuthenticationResult *result)
{
if (AD_SUCCEEDED != result.status){
// Show alert with error description
}
else{
//Handle Success token
}
}];
}else{
//Handle Success token
}
}];
但它总是抛出一个错误说"The user credentials are needed to obtain access token. Please call the non-silent acquireTokenWithResource methods."
有没有办法使用刷新令牌进行静默呼叫?请帮助我。提前致谢。