> py -m venv books
> cd books
> .\Scripts\activate
> pip install fastapi
> pip install uvicorn
run API in Local
> uvicorn books-api.main-api:app --reload
> py -m venv books
> cd books
> .\Scripts\activate
> pip install fastapi
> pip install uvicorn
run API in Local
> uvicorn books-api.main-api:app --reload
using System;
namespace dateCheck
{
public record Person(int id, string name);
class Program
{
static void Main(string[] args)
{
var person =
new Person(1, "FirstName");
}
}
}
namespace System.Runtime.CompilerServices
{
using System.ComponentModel;
/// <summary>
/// Reserved to be used by the compiler
for tracking metadata.
/// This class should not be used by
developers in source code.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
internal static class IsExternalInit
{
}
}
using (SqlConnection cn = getConnectionString())
{
string sql = "StoreProcName";
using (SqlCommand sqlCmd = new SqlCommand(sql, cn))
{
sqlCmd.CommandType = CommandType.StoredProcedure;
sqlCmd.Parameters.AddWithValue("@Param", "paramValue");
//cn.Open();
using (SqlDataAdapter sqlAdapter = new SqlDataAdapter(sqlCmd))
{
sqlAdapter.Fill(ds);
}
}
}
ds.Tables[0].Columns.Add("AreasOfInterest");
main = ds.Tables[0].ToList<Main>();
dates = ds.Tables[1].ToList<Dates>();
casOptions = ds.Tables[2].ToList<ModelName>();
var dataSet = new
DataSet();
using (var
context = new DataBase())
{
using
(var con = new SqlConnection(context.Database.Connection.ConnectionString))
{
using (var command = new SqlCommand("Sample_proc", con))
{
command.CommandType = CommandType.StoredProcedure;
command.Parameters.AddWithValue("@empId", id);
using (var adapter = new SqlDataAdapter(command))
{
adapter.Fill(dataSet);
}
}
}
using System;
using System.Collections.Generic;
using System.Configuration;
using System.IdentityModel.Tokens;
using System.Linq;
using Microsoft.Owin.Security;
using Microsoft.Owin.Security.ActiveDirectory;
using Owin;
using Microsoft.Owin.Security.Cookies;
using System.Globalization;
using Microsoft.Owin.Security.OpenIdConnect;
namespace Elite.Service
{
public partial class Startup
{
// For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864
public void ConfigureAuth(IAppBuilder app)
{
try
{
app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
ExpireTimeSpan = new TimeSpan(1, 0, 0)
});
app.UseOpenIdConnectAuthentication(
new OpenIdConnectAuthenticationOptions
{
ClientId = ConfigurationManager.AppSettings["ida:ClientID"],
Authority = String.Format(CultureInfo.InvariantCulture, ConfigurationManager.AppSettings["ida:AADInstance"], ConfigurationManager.AppSettings["ida:Tenant"]),
});
app.UseWindowsAzureActiveDirectoryBearerAuthentication(
new WindowsAzureActiveDirectoryBearerAuthenticationOptions
{
//Audience = ConfigurationManager.AppSettings["ida:Audience"],
Tenant = ConfigurationManager.AppSettings["ida:Tenant"],
TokenValidationParameters = new TokenValidationParameters { SaveSigninToken = true, ValidAudience = ConfigurationManager.AppSettings["ida:Audience"] }
});
}
catch (Exception ex)
{
// DB Error Logging
// App Insights Logging
}
}
}
}
<ns0:validate-jwt
var vc = new ValidationContext(myObject, null, null);
return Validator.TryValidateObject(myObject, vc, null, true);
someObject.GetType()
.GetProperties(BindingFlags.Instance | BindingFlags.Public)
.ToDictionary(prop => prop.Name, prop => prop.GetValue(someObject, null))
git rm --cached filename
git rm -r --cached .
git add .
git commit -m ".gitignore is now working"
int, double, etc.).
https://login.microsoftonline.com/{TenantId_or_Name}).
scope parameter when requesting an access token - without the need to pre-define them in the application registration information. If the user hasn't yet consented to new scopes added to the request, they'll be prompted to consent only to the new permissions. To learn more, see permissions, consent, and scopes.scope parameter gives developers full control over your user's experience. You can also front load your consent experience and ask for all permissions in one initial authorization request. If your app requires a large number of permissions, you can gather those permissions from the user incrementally as they try to use certain features of the app over time.AppID URI: https://graph.windows.net/oAuth2Permissions: Directory.Read, Directory.Write, and so on.GET https://login.microsoftonline.com/common/oauth2/authorize?
client_id=2d4d11a2-f814-46a7-890a-274a72a7309e
&resource=https://graph.windows.net/
...
GET https://login.microsoftonline.com/common/oauth2/v2.0/authorize?
client_id=2d4d11a2-f814-46a7-890a-274a72a7309e
&scope=https://graph.windows.net/directory.read%20https://graph.windows.net/directory.write
...
offline_accessscope. All apps will need to request this permission if they need to access resources on the behalf of a user for a prolonged period of time, even when the user may not be actively using the app. The offline_access scope will appear to the user in consent dialogs as Access your data anytime, which the user must agree to. Requesting the offline_access permission will enable your web app to receive OAuth 2.0 refresh_tokens from the v2.0 endpoint. Refresh tokens are long-lived, and can be exchanged for new OAuth 2.0 access tokens for extended periods of access.offline_access scope, it will not receive refresh tokens. This means that when you redeem an authorization code in the OAuth 2.0 authorization code flow, you'll only receive back an access token from the /token endpoint. That access token remains valid for a short period of time (typically one hour), but will eventually expire. At that point in time, your app will need to redirect the user back to the /authorize endpoint to retrieve a new authorization code. During this redirect, the user may or may not need to enter their credentials again or reconsent to permissions, depending on the type of app.refresh_tokens, and access_tokens, check out the v2.0 protocol reference.openid scope affords your app access to is now restricted. The openid scope will only allow your app to sign in the user and receive an app-specific identifier for the user. If you want to get personal data about the user in your app, your app needs to request additional permissions from the user. Two new scopes, emailand profile, will allow you to request additional permissions.email scope allows your app access to the user’s primary email address through the email claim in the id_token, assuming the user has an addressable email address.profile scope affords your app access to all other basic information about the user such as their name, preferred username, object ID, and so on in the id_token.https, and all redirect URL values must share a single DNS domain. The registration system compares the whole DNS name of the existing redirect URL to the DNS name of the redirect URL that you're adding. http://localhost is also supported as a redirect URL.https://login.contoso.com, you can add a redirect URL where the DNS name matches exactly, as shown in the following example:https://login.contoso.com/newhttps://new.login.contoso.comlogin-east.contoso.com and login-west.contoso.com as redirect URLs, you must add those redirect URLs in the following order:https://contoso.comhttps://login-east.contoso.comhttps://login-west.contoso.com.well-known endpoint for the v2.0 common endpoint is https://login.microsoftonline.com/common/v2.0/.well-known/openid-configuration. Replace common with your tenant ID to get data specific to your tenant.email claim is returned if an optional claim is configured or scope=email was specified in the request.scope parameter is now supported in place of the resource parameter.expires_in as an int instead of a string.