Skip to content

Instantly share code, notes, and snippets.

View bezysoftware's full-sized avatar

Tomas Bezouska bezysoftware

  • Step Up Labs, Inc.
  • Prague
View GitHub Profile
@bezysoftware
bezysoftware / Get-LnurlpMessages.ps1
Last active March 17, 2022 09:42
Get a list of LNURLp messages
$i = 0
$metadata
$metadataCounter = 0
$errorCounter = 0
$url = Read-Host "Enter LNURLp URL, e.g. https://wallet.paralelnipolis.cz/lnurlp/api/v1/lnurl/"
while ($true)
{
try
// subscribe to auth state changes
FirebaseUI.Instance.Client.AuthStateChanged += this.AuthStateChanged;
private void AuthStateChanged(object sender, UserEventArgs e)
{
// the callback is not guaranteed to be on UI thread
Application.Current.Dispatcher.Invoke(() =>
{
if (e.User == null)
{
<!--WPF Sample-->
<Page x:Class="Firebase.Auth.Wpf.Sample.LoginPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" mc:Ignorable="d" d:DesignHeight="450" d:DesignWidth="800"
xmlns:firebase="clr-namespace:Firebase.Auth.UI;assembly=Firebase.Auth.UI.WPF">
<Grid>
<firebase:FirebaseUIControl>
<firebase:FirebaseUIControl.Header>
<!--Custom content shown above the provider buttons-->
<TextBlock
HorizontalAlignment="Center"
Text="Hello world"
// Initialize FirebaseUI during your application startup (e.g. App.xaml.cs)
FirebaseUI.Initialize(new FirebaseUIConfig
{
ApiKey = "<API KEY>",
AuthDomain = "<DOMAIN>.firebaseapp.com",
Providers = new FirebaseAuthProvider[]
{
new GoogleProvider().AddScopes("email"),
new EmailProvider()
// and others
// user and auth properties
var user = userCredential.User;
var uid = user.Uid;
var name = user.Info.DisplayName; // more properties are available in user.Info
var refreshToken = user.Credential.RefreshToken; // more properties are available in user.Credential
// user methods
var token = await user.GetIdTokenAsync();
await user.DeleteAsync();
await user.ChangePasswordAsync("new_password");
// anonymous sign in
var user = await client.SignInAnonymouslyAsync();
// sign up or sign in with email and password
var userCredential = await client.CreateUserWithEmailAndPasswordAsync("email", "pwd", "Display Name");
var userCredential = await client.SignInWithEmailAndPasswordAsync("email", "pwd");
// sign in via provider specific AuthCredential
var credential = TwitterProvider.GetCredential("access_token", "oauth_token_secret");
var userCredential = await client.SignInWithCredentialAsync(credential);
@bezysoftware
bezysoftware / FirebaseAuthInit.cs
Last active January 12, 2020 11:10
Configure and initialize FirebaseAuthClient
using Firebase.Auth;
using Firebase.Auth.Providers;
using Firebase.Auth.Repository;
// Configure...
var config = new FirebaseAuthConfig
{
ApiKey = "<API KEY>",
AuthDomain = "<DOMAIN>.firebaseapp.com",
Providers = new FirebaseAuthProvider[]
public class SamlAuthenticationOptions : RemoteAuthenticationOptions
{
public string AuthorizationEndpoint { get; set; }
}
public void ConfigureServices(IServiceCollection services)
{
// ...
services
.AddAuthentication()
.AddGoogle(c =>
{
c.ClientId = "xyz.apps.googleusercontent.com";
c.ClientSecret = "top-secret";
});
private void Screenshot(int order, string lng)
{
float scale = 1.75f;
var size = new Size((int)(Screen.PrimaryScreen.WorkingArea.Width * scale), (int)(Screen.PrimaryScreen.WorkingArea.Height * scale));
using (var bitmap = new Bitmap(size.Width, size.Height))
{
using (var g = Graphics.FromImage(bitmap))
{