Table of contents


Unofficial Content

This article explains how to authenticate your users with WeChat using GeneXus Access Manager (GAM).

1. Enter to the GAM's Backend and go to the Authentication Types section. Create a new OAuth 2.0 Authentication Type and define basic information in the General section: Name, Description, Images (optional), etc.

2. In the Configuration section you need to define, for the General, Authorization, Token and User Information tab, the following:

General

Client ID:     appid        Value: <appid>
Client Secret: secret    Value: <secret>
Redirect URL:  redirect_uri     Value: https://<server>/webapp

Authorization

URL: https://open.weixin.qq.com/connect/qrconnect
Response type TAG:  response_type      Value: code
Scope TAG:          scope              Value: snsapi_login
State TAG:          state
Include ClientID and RedirectURL
Additional parameters:
Response:
Access code TAG: code
Error description TAG: errmsg

Token

URL: https://api.weixin.qq.com/sns/oauth2/access_token
Token Method: POST
Header Cotent type: Content-type      Value: application/x-www-form-urlencoded
Grant type:         grant_type        Value: authorization_code
Include Access Code:  True
Include Client Id:  True
Include Client Secret:  True
Include Redirect URL:  True
Response:
Access token TAG: access_token
Token type TAG:
Expires in TAG: expires_in
Scope Tag: scope
User Id Tag: openid
Refresh token Tag: refresh_token
Error Description Tag: errmsg

Refresh Token

Validate external token:  True
Refresh token URL:  https://api.wechat.com/sns/oauth2/refresh_token

User Information

URL: https://api.weixin.qq.com/sns/userinfo
Method: Post
Header Content type: Content-type      Value: application/json;charset=utf-8
Include Access Token:  True   Tag: access_token
Include Client Id:  False
Include Client Secret:  False
Include User Id:  True
Additional Parameters:  lang=en # Other options are zh_CN for Simplified Chinese, zh_TW for Traditional Chinese
Response
User Email Tag:  unionid
User External Id Tag:  unionid
User Name Tag:  unionid
User First Name: nickname  Generate automatic Last Name:  True
User Language Tag: language
Error Description Tag: errmsg

Availability

As of GeneXus 15 Upgrade 11.

See Also

GAM - OAuth 2.0 Authentication Type

    

Last update: November 2023 | © GeneXus. All rights reserved. GeneXus Powered by Globant