/// <summary> /// Gets a decrypted access token from the host platform OS. /// </summary> /// <param name="appId">An app/client id.</param> /// <returns></returns> public static byte[] GetToken(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) { return(GraphSession.Instance.MSALToken); } else { if (Helpers.OperatingSystem.IsWindows()) { return(WindowsTokenCache.GetToken(authContext.ClientId)); } else if (Helpers.OperatingSystem.IsMacOS()) { return(MacTokenCache.GetToken(authContext.ClientId)); } else { return(LinuxTokenCache.GetToken(authContext.ClientId)); } } }
/// <summary> /// Gets a decrypted access token from the host platform OS. /// </summary> /// <param name="appId">An app/client id.</param> /// <returns></returns> public static byte[] GetToken(string appId) { if (string.IsNullOrEmpty(appId)) { throw new ArgumentNullException(string.Format( CultureInfo.CurrentCulture, ErrorConstants.Message.NullOrEmptyParameter, nameof(appId))); } if (Helpers.OperatingSystem.IsWindows()) { return(WindowsTokenCache.GetToken(appId)); } else if (Helpers.OperatingSystem.IsMacOS()) { return(MacTokenCache.GetToken(appId)); } else { return(LinuxTokenCache.GetToken(appId)); } }