WorkPro 手册

登录成功

WorkPro认证页登录成功,会跳转给回调地址,并带上授权码

授权码只能使用一次,并在一分钟内失效

第三方系统根据授权码获取WorkPro的令牌,再做相关的操作

通过认证码获取令牌的地址是 http://WorkPro地址:8002/connect/oauth/token

参数是 client_id,client_secret,redirect_uri,code(授权码),通过POST方式提交

通过认证码获取令牌 PHP代码示例

		
	$url = $this->appInfo['im_server'] . '/connect/oauth/token' ;
	$code = $_GET['code'];
	
	$data = [
		'code'=>$code,
		'redirect_uri'=>$this->appInfo['redirect_uri'],
		'client_id'=>$this->appInfo['client_id'],
		'client_secret'=>$this->appInfo['client_secret'],
		'grant_type'=>'authorization_code',
	];

	$curl = curl_init();
	curl_setopt($curl, CURLOPT_URL, $url);
	curl_setopt($curl, CURLOPT_HEADER, 0);
	curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
	curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);// https请求 不验证证书
	curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);// https请求 不验证hosts
	curl_setopt($curl, CURLOPT_POST, 1);
	curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
	$res = curl_exec($curl);
	curl_close($curl);

	$res = json_decode($res,true);
	if (! $res['status']){
		echo 'code无效';
	}else{
		echo '当前用户ID:' . $res['data']['user_id'] ;
	}