azure-activedirectory-library-for-cordova
azure-activedirectory-library-for-cordova copied to clipboard
msadal - acquireTokenSilentAsync doesn't works until "userId" is passed, even it is optional as per docs.
I've encountered an issue while using 'acquireTokenSilentAsync()' through 'msadal' in 'ionic v5'.
Its given in docs that 'userId' is optional.
Docs:
Expected:
/**
* Acquires token WITHOUT using interactive flow. It checks the cache to return existing result
* if not expired. It tries to use refresh token if available. If it fails to get token without
* displaying UI it will fail. This method guarantees that no UI will be shown to user.
*
* @param {String} resourceUrl Resource identifier
* @param {String} clientId Client (application) identifier
* @param {String} userId User identifier (optional)
* @returns {Promise} Promise either fulfilled with AuthenticationResult object or rejected with error
*/
acquireTokenSilentAsync(resourceUrl: string, clientId: string, userId?: string): Promise<AuthenticationResult>;
Error:
Wrong type for parameter "userId" of AuthenticationContext.acquireTokenSilentAsync: Expected String, but got Function.
TypeError: Wrong type for parameter "userId" of AuthenticationContext.acquireTokenSilentAsync: Expected String, but got Function.
But, method doesn't make call until I passed an empty string as the parameter.
Workaround:
// request for token using configuration from environment.
this.authContext.acquireTokenSilentAsync(msadalConfig.resourceUrl, msadalConfig.clientId, "")
@gg0305 This library is archived and they haven't been updating the acquireTokenSilentAsync signature methods. I ended up using a forked version where the signature api reflects the native acquireTokenSilentAsync api.
@leewhitbeck did have the url of forked rep ? is there any forked rep that fixed the problem of UiWebView ?
@fradali , here is the forked repo we used. We have the app disabled, but I don't think it has fixed the UiWebView issue.
@gg0305 did you find a solution ?
@webteambel which solution? the "userID" to be passed?