We are having issues getting the refresh tokens to work. Initially the user logs in using the web view from ADAL and gets a token. That token is used to call the Web API until it expires. Instead of getting a new token without the web prompt as we would expect, an error is logged on the server and the user is shown the login web prompt again.
From what we have read you are supposed to use AcquireTokenAsync on every call and let ADAL handle the tokens/refresh tokens.
Here is the error we get on the server when ADAL tries to get a new token using the refresh token. We've tried searching for that error but don't find much.
Encountered error during OAuth token request.
Additional Data
Exception details: Microsoft.IdentityServer.Web.Protocols.OAuth.Exceptions.OAuthInvalidScopeException: MSIS9330: The OAuth access token request received is invalid. A 'scope' parameter was received in the request and AD FS does not support any scope. Received scope: 'openid'. at Microsoft.IdentityServer.Web.Protocols.OAuth.OAuthToken.OAuthRefreshTokenRequestContext.Validate()
Are we missing something ? Is there a way to set the scope or does this just not work with the current versions we are using ? ADAL is the one making the post with the scope to the ADFS server.
We are NOT using Azure AD !
The call from the view controller in the iOS app:
PlatformParameters p = new PlatformParameters(this);
AuthenticationContext authContext = new AuthenticationContext("https://adfs.domain.com/adfs", false);
AuthenticationResult _authResult = await authContext.AcquireTokenAsync("https://webapi.domain.com", "E1CF1107-FF90-4228-93BF-26052DD2C714", “http://anarbitraryreturnuri/”, p);
Startup.Auth.cs in Web API:
public void ConfigureAuth(IAppBuilder app)
{
app.UseActiveDirectoryFederationServicesBearerAuthentication(
new ActiveDirectoryFederationServicesBearerAuthenticationOptions
{
MetadataEndpoint = ConfigurationManager.AppSettings["ida:AdfsMetadataEndpoint"],
TokenValidationParameters = new TokenValidationParameters()
{
ValidAudience = ConfigurationManager.AppSettings["ida:Audience"],
},
}
}
Here are the pieces we have:
- Windows Server 2012 R2 with ADFS 3.0(on premises)
- SsoLifetime = 60
- TokenLifetime(relying party) = 10
- ADAL 3.13.8
- .NET Web API
- Xamarin iOS app
Here are some of the posts we used to get this working: