Dotnetopenauth-based OAuth Implementation sample code: How to get access token

Source: Internet
Author: User
Tags oauth

1. Scene

According to the OAuth 2.0 specification, the scenario takes place in the (D) (E) node of the following flowchart, obtaining access token based on the authorization code that has been obtained.

2. Realize the Environment

Dotnetopthauth v5.0.0-alpha3, ASP.net MVC 5,. NET Framework 4.5.1.

2. Main implementation Sample code

2.1. Authorization Server Implementation Code

2.1.1. asp.net MVC Controller Implementation code

Using System.Threading.Tasks;
Using SYSTEM.WEB.MVC;
Using CNBlogs.Open.Domain.Entities.OpenAuth;
Using Dotnetopenauth.oauth2;
Using Dotnetopenauth.messaging;
    
Namespace CNBlogs.Open.Web.Controllers
{public
    class Oauthcontroller:controller
    {public
        async Task<actionresult> Token ()
        {
            var authserver = new Authorizationserver (new Authorizationserverhost ()) ;
            var response = await authserver.handletokenrequestasync (Request);
            return response. Asactionresult ();}}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.