Giter VIP home page Giter VIP logo

firebase-authentication-net-demo's People

Contributors

singletonsean avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

firebase-authentication-net-demo's Issues

Issue creating EF Migrations with this package

This package seems to cause some issues when trying to add migrations with EF tools. Some quick googling has showed that it may only be an issue with initial migration. Leaving this issue open for a bit while I debug.

Error Code:

PM> Add-Migration InitialCreate
Build started...
Build succeeded.
An error occurred while accessing the Microsoft.Extensions.Hosting services. Continuing without the application service provider. Error: Some services are not able to be constructed (Error while validating the service descriptor 'ServiceType: FirebaseAdminAuthentication.DependencyInjection.Services.FirebaseAuthenticationHandler Lifetime: Transient ImplementationType: FirebaseAdminAuthentication.DependencyInjection.Services.FirebaseAuthenticationHandler': Unable to resolve service for type 'FirebaseAdmin.FirebaseApp' while attempting to activate 'FirebaseAdminAuthentication.DependencyInjection.Services.FirebaseAuthenticationFunctionHandler'.) (Error while validating the service descriptor 'ServiceType: FirebaseAdminAuthentication.DependencyInjection.Services.FirebaseAuthenticationFunctionHandler Lifetime: Scoped ImplementationType: FirebaseAdminAuthentication.DependencyInjection.Services.FirebaseAuthenticationFunctionHandler': Unable to resolve service for type 'FirebaseAdmin.FirebaseApp' while attempting to activate 'FirebaseAdminAuthentication.DependencyInjection.Services.FirebaseAuthenticationFunctionHandler'.)
Unable to create an object of type 'DatabaseContext'. For the different patterns supported at design time, see https://go.microsoft.com/fwlink/?linkid=851728

Packages:

<Project Sdk="Microsoft.NET.Sdk.Web">

    <PropertyGroup>
        <TargetFramework>net7.0</TargetFramework>
        <Nullable>enable</Nullable>
        <ImplicitUsings>enable</ImplicitUsings>
    </PropertyGroup>

    <ItemGroup>
        <PackageReference Include="FirebaseAdmin" Version="2.4.0" />
        <PackageReference Include="FirebaseAdminAuthentication.DependencyInjection" Version="1.1.0" />
        <PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="7.0.7" />
        <PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.9" />
        <PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="7.0.9" />
        <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.9" />
        <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.9">
          <PrivateAssets>all</PrivateAssets>
          <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
        </PackageReference>
        <PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
    </ItemGroup>

    <ItemGroup>
      <Folder Include="Context\Migrations\" />
      <Folder Include="Controllers\" />
    </ItemGroup>

</Project>

Program.cs

using api.context;
using FirebaseAdmin;
using FirebaseAdmin.Auth;
using FirebaseAdminAuthentication.DependencyInjection.Extensions;
using Google.Apis.Auth.OAuth2;
using Microsoft.EntityFrameworkCore;

var builder = WebApplication.CreateBuilder(args);

// Add services to the container.

builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();

// Adding CORS policies
builder.Services.AddCors(options =>
{
    options.AddPolicy("DevelopmentPolicy",
        builder =>
        {
            builder.WithOrigins("http://localhost:3000") // Adjust this to your local development URL
                .AllowAnyHeader()
                .AllowAnyMethod()
                .AllowCredentials();
        });
});

FirebaseApp.Create(new AppOptions()
{
    Credential = GoogleCredential.FromJson(builder.Configuration.GetValue<string>("FIREBASE_CFG"))
});

builder.Services.AddDbContext<DatabaseContext>(options =>
    options.UseSqlServer(builder.Configuration.GetConnectionString("Server=(localdb)\\MSSQLLocalDB;Database=team.organizer.db")));


builder.Services.AddFirebaseAuthentication();
builder.Services.AddAuthorization();

var app = builder.Build();

// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
    app.UseSwagger();
    app.UseSwaggerUI();
}

app.UseHttpsRedirection();

// Use the CORS policy
app.UseCors("DevelopmentPolicy");

app.UseAuthorization();
app.UseAuthentication();

app.MapControllers().RequireAuthorization();

app.Run();

What licence does this project have?

Hi @SingletonSean, I've sent a message via nuget.org but I'm not sure if you're going to see it there so I'm posting here since it's hopefully more likely to be seen.

I'd like to use this package in my projects (personal or possibly commercial projects to be owned by others) but there's no licence mentioned in this repo or in nuget.org. More specifically, I'd like to use my own modified fork of it (here - side question: are you open to contributions?), but without a licence I can't assume I have any rights to use or modify it at all. While it's simple code, and made for your tutorials where you likely expect people to copy and use it, I'd like to make sure.

Can you confirm whether or not I have permission to use it, and my own modified versions of it, and redistribute it in my personal and commercial projects?

Cheers

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.