コード例 #1
0
        /// <summary>
        /// Deletes an access token from the host OS.
        /// </summary>
        /// <param name="appId">An app/client id.</param>
        public static void DeleteToken(IAuthContext authContext)
        {
            if (string.IsNullOrEmpty(authContext.ClientId))
            {
                throw new ArgumentNullException(string.Format(
                                                    CultureInfo.CurrentCulture,
                                                    ErrorConstants.Message.NullOrEmptyParameter,
                                                    nameof(authContext.ClientId)));
            }

            if (authContext.ContextScope == ContextScope.Process)
            {
                GraphSession.Instance.MSALToken = null;
            }
            else
            {
                if (Helpers.OperatingSystem.IsWindows())
                {
                    WindowsTokenCache.DeleteToken(authContext.ClientId);
                }
                else if (Helpers.OperatingSystem.IsMacOS())
                {
                    MacTokenCache.DeleteToken(authContext.ClientId);
                }
                else
                {
                    LinuxTokenCache.DeleteToken(authContext.ClientId);
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Deletes an access token from the host OS.
        /// </summary>
        /// <param name="appId">An app/client id.</param>
        public static void DeleteToken(string appId)
        {
            if (string.IsNullOrEmpty(appId))
            {
                throw new ArgumentNullException(string.Format(
                                                    CultureInfo.CurrentCulture,
                                                    ErrorConstants.Message.NullOrEmptyParameter,
                                                    nameof(appId)));
            }

            if (Helpers.OperatingSystem.IsWindows())
            {
                WindowsTokenCache.DeleteToken(appId);
            }
            else if (Helpers.OperatingSystem.IsMacOS())
            {
                MacTokenCache.DeleteToken(appId);
            }
            else
            {
                LinuxTokenCache.DeleteToken(appId);
            }
        }