最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
当前位置: 首页 - 科技 - 知识百科 - 正文

WSO2IS4.6.0报错:Accesstokenidentifierisnotpresentin

来源:动视网 责编:小采 时间:2020-11-09 07:43:02
文档

WSO2IS4.6.0报错:Accesstokenidentifierisnotpresentin

WSO2IS4.6.0报错:Accesstokenidentifierisnotpresentin:最近用client 向 IS判断access token是否合法,在使用编写代码测试时,发现OAuth2TokenValidationServiceStub.validate()一直失败。 代码如下: OAuth2TokenValidationServiceStub stub = null;String serviceURL
推荐度:
导读WSO2IS4.6.0报错:Accesstokenidentifierisnotpresentin:最近用client 向 IS判断access token是否合法,在使用编写代码测试时,发现OAuth2TokenValidationServiceStub.validate()一直失败。 代码如下: OAuth2TokenValidationServiceStub stub = null;String serviceURL


最近用client 向 IS判断access token是否合法,在使用编写代码测试时,发现OAuth2TokenValidationServiceStub.validate()一直失败。 代码如下: OAuth2TokenValidationServiceStub stub = null;String serviceURL = OAuth2ClientServlet.serverUrl + OAuth2T

最近用client 向 IS判断access token是否合法,在使用编写代码测试时,发现OAuth2TokenValidationServiceStub.validate()一直失败。

代码如下:

 OAuth2TokenValidationServiceStub stub = null;
	String serviceURL = OAuth2ClientServlet.serverUrl + "OAuth2TokenValidationService";
	try {
	stub = new OAuth2TokenValidationServiceStub(null, serviceURL);
	} catch (AxisFault e) {
	// TODO Auto-generated catch block
	e.printStackTrace();
	}
	CarbonUtils.setBasicAccessSecurityHeaders(OAuth2ClientServlet.userName, OAuth2ClientServlet.password, true, stub._getServiceClient());
	ServiceClient client = stub._getServiceClient();
	Options options = client.getOptions();
	options.setTimeOutInMilliSeconds(TIMEOUT_IN_MILLIS);
	options.setProperty(HTTPConstants.SO_TIMEOUT, TIMEOUT_IN_MILLIS);
	options.setProperty(HTTPConstants.CONNECTION_TIMEOUT, TIMEOUT_IN_MILLIS);
	options.setCallTransportCleanup(true);
	options.setManageSession(true);
	
	OAuth2TokenValidationRequestDTO oauthReq = new OAuth2TokenValidationRequestDTO();
	oauthReq.setAccessToken(accessToken);
	oauthReq.setTokenType("bearer");
	
	try {

	bool resp = stub.validate(params);
	} catch (RemoteException e) {
	// TODO Auto-generated catch block
	e.printStackTrace();
	}
	
	

后google,发现:http://stackoverflow.com/questions/20796574/oauth-validation-fails-for-valid-token-in-wso2-is-4-6


I faced the same problem with OAuth Mediator in Wso2 ESB 4.8.0 accessing Wso2 Identity Server 4.6.0 via Oauth2 validation web service. With Identity server 4.5.0 it works fine.The mediator code invokes the client stub passing the accessToken as plain string.

The error message returned by validation service is Access token identifier is not present in the validation request.

To answer your question you should use the bundle org.wso2.carbon.identity.oauth.stub in version 4.2.2. It defines a class org.wso2.carbon.identity.oauth2.stub.dto.OAuth2TokenValidationRequestDTO_OAuth2AccessToken which should be used as a parameter for the OAuth2TokenValidationRequestDTO.setAccessToken method. The dto object can the be used as parameter for the OAuth2TokenValidationServiceStub.validate method.

居然是版本问题!


所以:将代码修改为下面即可:


 OAuth2TokenValidationRequestDTO oauthReq = new OAuth2TokenValidationRequestDTO();
OAuth2TokenValidationRequestDTO_OAuth2AccessToken oauthReq_token 
	= new OAuth2TokenValidationRequestDTO_OAuth2AccessToken();

oauthReq_token.setTokenType("bearer");
oauthReq_token.setIdentifier(accessToken);
oauthReq.setAccessToken(oauthReq_token);


文档

WSO2IS4.6.0报错:Accesstokenidentifierisnotpresentin

WSO2IS4.6.0报错:Accesstokenidentifierisnotpresentin:最近用client 向 IS判断access token是否合法,在使用编写代码测试时,发现OAuth2TokenValidationServiceStub.validate()一直失败。 代码如下: OAuth2TokenValidationServiceStub stub = null;String serviceURL
推荐度:
标签: in is 报错
  • 热门焦点

最新推荐

猜你喜欢

热门推荐

专题
Top