Small example using Xamarin Forms 2.5, MVC5 and web api.
Login in Xamarin Forms 2.5 with our API. Get, create, delete and update (CRUD) records from Xamarin Forms from our API. All queries from Xamarin Forms are made with token.
Configure a connection string for SQL Server in the Web.config
<connectionStrings>
<add name="DefaultConnection" connectionString="Data
Source=YOURTDATABASE;
Initial Catalog=YOURNAMEDB; Persist Security
Info=True;User ID=YOURUSER;Password=YOURPASSWORD”"
providerName="System.Data.SqlClient" />
</connectionStrings>-->
By default, if you don't customise anything, Identity configures a default set of validation rules for new passwords. If you want to change these values, you can change the file called App_Start/IdentityConfig.cs
manager.PasswordValidator = new PasswordValidator
{
RequiredLength = 6, // Passwords must be at least 6 characters
RequireNonLetterOrDigit = false, // Passwords must have at least one digit ('0'-'9')
RequireDigit = false, // Passwords must have at least one non alphanumeric character
RequireLowercase = false, // // Passwords must have at least one lowercase ('a'-'z')
RequireUppercase = false, // Passwords must have at least one uppercase ('A'-'Z')
};
In our PCL, the file App.xaml you can change the color
<Color x:Key="MainColor">#273646</Color>
<Color x:Key="FontColor">#2d8dd6</Color>
<Color x:Key="AccentColor1">#2371aa</Color>
<Color x:Key="AccentColor2">#e44235</Color>
<Color x:Key="BackgroundColor">#e9eeef</Color>
In our PCL, the file Services/HttpService.cs you must put the url of your api and prefix
private const string UrlApi = "YOURAPI";
private const string tokenType = "bearer";
protected const string FirstVersion = "/api";
- Rest api tutorial - Microsoft
- Rest api tutorial - hackernoon
- Rest api tutorial - code-maze
- Rest api tutorial - solidgeargroup
OAuth 2.0 protocol and Microsoft Owin Library will help us. Owin is basically creating own pipeline between iis and application to manage requests.
In the file Startup.Auth.cs an OWIN Authorization server is configured to accept login (token) HTTP requests at /Token endpoint and external login requests at /api/Account/ExternalLogin
Plugin | Project |
---|---|
EntityFramework | Model |
Newtonsoft | Model |
Plugin | Author |
---|---|
Settings | james montemagno |
MvvmLightLibsStd10 | galasoft |
Connectivity | james montemagno |
Newtonsoft | james Newton-King |
Image Circle | james montemagno |
The following tools are essential:
- Genymotion - The Best Android Emulator
- Postman - Application which is used to fire requests to an API. It is possible to make different kinds of HTTP requests – GET, POST, PUT, PATCH and DELETE.
- Quicktype - Generate c# classes from json.
- Color Adobe - To create color schemes for my designs. For this project I have choosen https://color.adobe.com/Flat-UI-color-theme-2469224/
Getting Started with ASP.NET MVC 5
The MIT License (MIT) see License file