WeiboOAuth2.Provider 1.0.2

.NET Standard 2.0
dotnet add package WeiboOAuth2.Provider --version 1.0.2
NuGet\Install-Package WeiboOAuth2.Provider -Version 1.0.2
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="WeiboOAuth2.Provider" Version="1.0.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add WeiboOAuth2.Provider --version 1.0.2
#r "nuget: WeiboOAuth2.Provider, 1.0.2"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install WeiboOAuth2.Provider as a Cake Addin
#addin nuget:?package=WeiboOAuth2.Provider&version=1.0.2

// Install WeiboOAuth2.Provider as a Cake Tool
#tool nuget:?package=WeiboOAuth2.Provider&version=1.0.2

WeiboOAuth2.Provider

Weibo OAuth 2.0 provider for .net core 2.0

github : https://github.com/ws-dotnet-core/WeiboOAuth2.Provider

nuget(current version) : https://www.nuget.org/packages/WeiboOAuth2.Provider/1.0.2

UPDATE

2017.10.02 :

  1. change the main namespace to "WeiboOAuth2.Provider", not "WeiboOAuth2.Provider.Src" .
  2. fix the problem of no-error-return when redirect_url is wrong.

Weibo OAuth 2.0

[T]: Implemented
[F]: Not implemented

OAuth2(Guider)VERSION 1.0.0
[T]Request authorization:	oauth2/authorize	
[T]Get authorization:	oauth2/access_token	
[F]Authorization Query:	oauth2/get_token_info	
[F]Replace authorization:	oauth2/get_oauth2_token	
[T]Authorization Recycle:	oauth2/revokeoauth2	
Other interfaces:	
  [F]account/rate_limit_status	Gets the current authorized user API Access frequency limit
  [F]account/get_uid	        To obtain a user's UID after authorization
  [F]account/profile/email	        Get user's contact mailbox after authorization
  [T]https://api.weibo.com/2/users/show.json      get user infos

Package Manager

PM > Install-Package WeiboOAuth2.Provider -Version 1.0.2

.NET CLI

> dotnet add package WeiboOAuth2.Provider --version 1.0.2

Dependencies :

.NETStandard 2.0

Newtonsoft.Json (>= 10.0.3)

How to use:

1. Create options for WeiboOAuth2.0 and inject it into container

    public class WeiboOAuthV2Option : IWeiboOAuthV2Option {
        public string AppID => "your app id";
        public string AppSecret => "your app secret";
    }

    // ...... then inject it.

    services.AddScoped<IWeiboOAuthV2Option, WeiboOAuthV2Option>();

2. Then create your service

    // new interface for web service provider
    public interface IWeiboOAuthService<TUser> : IWeiboOAuthV2Provider<WeiboSuccessToken, WeiboUser> {
        // add your code here.
    }

    public class WeiboOAuthService : WeiboOAuthV2Provider, IWeiboOAuthService<User> {

        private YourDBContext db;

        public WeiboOAuthService(YourDBContext db, IWeiboOAuthV2Option options) : base(options) {
            this.options = options;
            this.db = db;
        }

    }

    // then inject it

    services.AddScoped<IWeiboOAuthService<User>, WeiboOAuthService>();

3. Use in controller

public class IdentityController : Controller {

        private YourDBContext db;
        private IWeiboOAuthService<User> weibo;

        public IdentityController(YourDBContext db, IWeiboOAuthService<User> WEOBO_SRV) {
            this.db = db;
            this.weibo = WEOBO_SRV;
        }

4. Request authorization (frontend)

// example in typescript
public get WeiboAuth() {
    // my regex tools : ws-regex (npm)
    const href = Regex.Create(/htt.+\/\/.+?\//).Matches(window.location.href)[0];
    return `${this.server.WeiboOAuthHost}/authorize?client_id=${this.server.WeiboClientID}&response_type=code&redirect_uri=${href}`;
  }

5. Get authorization

 var (result, succeed, error) = await this.weibo.GetWeiboTokenByCodeAsync(code, redirect_url);

6. Get userinfos

var (infos, succeed02, error02) = await this.weibo.GetWeiboUserInfosAsync(result.Uid, result.AccessToken);

7. Authorization Recycle

var (result, succeed, error) = await this.weibo.RevokeOAuth2Access(access_token);
Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows net7.0 net7.0-android net7.0-ios net7.0-maccatalyst net7.0-macos net7.0-tvos net7.0-windows
.NET Core netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard2.0 netstandard2.1
.NET Framework net461 net462 net463 net47 net471 net472 net48
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen tizen40 tizen60
Xamarin.iOS xamarinios
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.2 1,217 10/2/2017
1.0.1 821 10/2/2017
1.0.0 843 10/1/2017

fix the problem of no-error-return when redirect_url is wrong.