การเชื่อมต่อ OAuth2 ด้วย .NET C#
อยาก Login ด้วย OAuth2 กับ .NET C# ต้องทำอย่างไร สำหรับตัวอย่างนี้เอามาจาก GitHub Project : https://github.com/titarenko/OAuth2[1] ซึ่งเป็น Code ตัวอย่างนำมาเพิ่ม ในส่วนของการเชื่อมต่อ PSU Passport ดังนี้ เพิ่ม class file ใน project OAuth2->Client->Impl ชื่อ PassportClient.cs เนื้อหาดังนี้ using Newtonsoft.Json.Linq; using OAuth2.Configuration; using OAuth2.Infrastructure; using OAuth2.Models; namespace OAuth2.Client.Impl { /// <summary> /// Passport authentication client. /// </summary> public class PassportClient : OAuth2Client { /// <summary> /// Initializes a new instance of the <see cref=”PassportClient”/> class. /// </summary> /// <param name=”factory”>The factory.</param> /// <param name=”configuration”>The configuration.</param> public PassportClient(IRequestFactory factory, IClientConfiguration configuration) : base(factory, configuration) { } /// <summary> /// Defines URI of service which issues access code. /// </summary> protected override Endpoint AccessCodeServiceEndpoint { get { return new Endpoint { BaseUri = “https://oauth.psu.ac.th”, Resource = “?oauth=authorize” }; } } /// <summary> /// Defines URI of service which issues access token. /// </summary> protected override Endpoint AccessTokenServiceEndpoint { get { return new Endpoint { BaseUri = “https://oauth.psu.ac.th”, Resource = “?oauth=token” }; } } /// <summary> /// Defines URI of service which allows to obtain information about user which is currently logged in. /// </summary> protected override Endpoint UserInfoServiceEndpoint { get { return new Endpoint { BaseUri = “https://oauth.psu.ac.th”, Resource = “?oauth=me” }; } } /// <summary> ///