oauth

OAuth模块管理客户端的用户登录授权验证功能,允许应用访问第三方平台的资源。

方法:

对象:

回调方法:

权限:

permissions

{
// ...
"permissions":{
	// ...
	"OAuth": {
		"description": "登录鉴权"
	}
}
}
			

AuthService

登录授权认证服务对象

interface plus.oauth.AuthService {
	// Attributes
	attribute String id;
	attribute String description;
	attribute AppleInfo appleInfo;
	attribute AuthInfo authResult;
	attribute UserInfo userInfo;
	attribute JSON extra;
	
	// Methods 
	function void author(successCallback, errorCallback, options);
	function void login(successCallback, errorCallback, options);
	function void logout(successCallback, errorCallback);
	function void getUserInfo(successCallback, errorCallback);
	function void addPhoneNumber(successCallback, errorCallback);
}
				

说明:

AuthService对象用于表示登录授权认证服务,在JS中为对象,用于向系统进行登录授权认证操作。

属性:

方法:

AppleInfo

苹果登录认证信息

interface plus.oauth.AppleInfo {
	attribute String user;
	attribute String state;
	attribute String email:
	attribute JSON fullName;
	attribute String authorizationCode;
	attribute String identityToken;
	attribute Number realUserStatus;
	attribute String scope;
}
				

说明:

此对象仅在使用苹果登录时有效,用于保存苹果登录返回的数据。

属性:

AuthOptions

JSON对象,授权认证参数选项

interface plus.oauth.AuthOptions {
	attribute String scope;
	attribute String state;
	attribute String appid;
	attribute String appkey;
	attribute String appsecret;
	attribute String redirect_uri;
}
				

说明:

此对象支持的属性值由登录授权认证服务定义。 例如“微信”,则可配置以下参数: scope - 应用授权作用域; state - 用于保持请求和回调的状态参数。

属性:

AuthInfo

登录授权认证信息

interface plus.oauth.AuthInfo {
	attribute String openid;
	attribute String access_token;
	attribute String expires_in:
	attribute String refresh_token;
	attribute String scope;
}
				

说明:

此对象仅定义标准属性,登录授权认证服务可扩展自定义数据。 例如“微信”登录授权服务,则包括以下数据: unionid - 用户统一标识,针对一个微信开放平台帐号下的应用,同一用户的unionid是唯一的。

属性:

UserInfo

登录授权用户信息

interface plus.oauth.UserInfo {
	attribute String openid;
	attribute String headimgurl:
	attribute String nickname;
	attribute String email;
	attribute String phonenumber;
	attribute String sex;
	attribute String province;
	attribute String city;
	attribute String country;
}
				

说明:

用于保存登录授权用户的信息。 此对象仅定义标准属性,登录授权认证服务可扩展自定义数据。 例如“微信”登录授权服务,可能包括以下自定义数据: privilege - 用户特权信息,json数组,如微信沃卡用户为(chinaunicom); unionid - 用户统一标识,针对一个微信开放平台帐号下的应用,同一用户的unionid是唯一的。

属性:

ServicesSuccessCallback

获取登录授权认证服务成功回调

void ServicesSuccessCallback( services ) {
	// Get oauth services success code
}
				

说明:

当获取登录授权认证服务列表成功时触发,并通过services参数返回运行环境支持的登录授权认证服务列表。

参数:

返回值:

void : 无

AuthorizeSuccessCallback

授权认证成功回调函数

void onAuthorizeSuccess(event){
	  // authorize code
}
				

说明:

授权认证成功时触发,并返回操作结果。

参数:

返回值:

void : 无

LogoutSuccessCallback

注销登录授权认证操作成功回调函数

void onLogoutSuccess(event){
	  // logout code
}
				

说明:

注销登录授权认证成功时触发,并返回操作结果。

参数:

返回值:

void : 无

SuccessCallback

登录授权认证服务操作成功回调函数

void onSuccess(event){
	  // auth code
}
				

说明:

登录授权认证服务操作如请求登录授权认证、获取登录授权用户信息成功时触发,并返回操作结果。

参数:

返回值:

void : 无

ErrorCallback

登录授权认证服务操作失败回调函数

void onError(error){
	// Error code
}
				

说明:

登录授权认证服务操作如请求登录授权认证、注销登录授权认证、获取登录授权用户信息失败时触发,并返回错误信息。

参数:

返回值:

void : 无