public static IDisposable Create(string cloudName, string refreshToken) { IntPtr itemRef = IntPtr.Zero; try { MacosNativeMethods.SecKeychainAddGenericPassword(IntPtr.Zero, ExpectedServiceName, cloudName, refreshToken, out itemRef); } finally { MacosNativeMethods.CFRelease(itemRef); } return(new OsxRefreshTokenFixture(cloudName)); }
public void Dispose() { IntPtr credentialsPtr = IntPtr.Zero; IntPtr itemRef = IntPtr.Zero; try { MacosNativeMethods.SecKeychainFindGenericPassword(IntPtr.Zero, ExpectedServiceName, _cloudName, out _, out credentialsPtr, out itemRef); MacosNativeMethods.SecKeychainItemDelete(itemRef); } finally { try { MacosNativeMethods.SecKeychainItemFreeContent(IntPtr.Zero, credentialsPtr); } finally { MacosNativeMethods.CFRelease(itemRef); } } }