Skip to main content

Add WeCom as an OAuth provider

This guide explains how to let users sign in to Casdoor from the WeCom (WeChat Work) client. You can connect an internal application or a third-party application of WeCom.


Learning outcomes​

  • Choose the sub type, the method, and the scope.
  • Add WeCom as an OAuth provider in Casdoor.

What you need​


Add the provider in Casdoor​

  1. In the Casdoor admin console, go to Identity > Providers and add a provider.

  2. Set Category to OAuth and Type to WeCom.

  3. Fill in the fields:

    Casdoor fieldDescription
    Sub typeInternal or Third-party
    MethodSilent or Normal
    Client IDInternal: enterprise CorpID. Third-party: CorpID of the service provider
    Client secretInternal: Secret of the application (CorpSecret). Third-party: ProviderSecret of the service provider
    Agent IDInternal only: application AgentId
    Scopesnsapi_userinfo (default) or snsapi_privateinfo, used only by the Silent method
  4. Save the provider.

Methods​

MethodBehavior
SilentWeb authorization (open.weixin.qq.com/connect/oauth2/authorize) for pages opened in the WeCom client. WeCom redirects the user to redirect_uri?code=CODE&state=STATE without asking
NormalWeCom web login (login.work.weixin.qq.com/wwlogin/sso/login). The user scans a QR code with the WeCom mobile app, or signs in quickly from the WeCom desktop client

See WeCom OAuth and WeCom web login.

Scopes​

Casdoor sends the scope only with the Silent method.

ScopeData
snsapi_userinfoThe basic profile, without the email address. The current WeCom documentation no longer lists this value and names the silent scope snsapi_base instead
snsapi_privateinfoAlso the email address and other sensitive data. WeCom asks the user to authorize, and the user must be in the visible range of the application. The administrator of the enterprise must grant the application the permission for sensitive member information

Use an internal application with the Silent method and snsapi_privateinfo if Casdoor should fill in the email address of users from WeCom.

Next steps​

Add the provider to an application. See Add providers to an application.

See also​