0

Got 401 Authorization Required error, when call YMWS

I used the sample code got from https://developer.yahoo.com/mail/code/;

The program language is java, and I use java-ws; What I did is the following,

Create some dependent java class by,

importer: wsimport -extension -s src -p com.yahoo.mail https://mail.yahooapis.com/ws/mail/v1.1/wsdl

In the Sample Code, I filled teh correct appid, secret and access_token. I know the sample code is using BBAuth; to use the OAuth, I just did a little change,

String url = "<https://mail.yahooapis.com/ws/mail/v1.1/soap?oauth_signature=eVg3ewgzTWicgs6YWsBRXLgpUrY%3D&oauth_version=1.0&oauth_nonce=294255886&oauth_signature_method=HMAC-SHA1&oauth_consumer_key=bafce774f772246c6c3e970fefcfa521442ff694&oauth_token=A%3Df7Dabf3skjaYNB3..MolxMPUtwgdbwsWEPdpeNoenCCBMQ7n3r.PEUnK7OlQbkGRpCLT4LCDx_b57pTbTHzj2bvNMAV4yrkXJ75Imck5qgNqKBGcwo_tnhvzY2r3vWzI93_C9RgwZO0r64w3qDiGo6Ou50mGm_z0_qDL2NmzYRXFfLeImkJbmIRQjlHeyxqchpefFPUBWtuQdN97JRLIFG19eEMO23EkAvyymRrYj8YZRQ58_Sz7.yhNw6HbH_My9JWVf1h.b.vq3gEKfxnROZn7EHxVaVh1DD_9SHgW_KJRRLJZCShO2QFerjz0SfJVwr5Rg_YN0WazYhv.WuGTwaBsSt47IpmqbAn1AGf4DgLHjitqyQSLGQG5zvlmlECl2xO.1GTc38y9f6_PqmnceeoLTtoIwIqvzDZiTW2tm0.NLnfn1v2l.MdyvwtS7WM3mQSyV4WPZ5yquK20xlgE6SU1sjGAw_XPLBa5bkCzXbZv46PegYy8WRcn5tgSd_90LhsYhCAa3OxCyHWqHVvTJmFtiAapo9OLMbg3C.hg_bWeG1Y6sKkVskly7Lju01wrfjAmFWi.2M2co3tjtKlgkBxrixTw9LMDEnmMZXHoit7KN9ru.AXDF7ZQlM6rCm26GZNgyubYg2_d31puQBxy1GjyIP02g5aPEm0mwkQbdfpONqWXxvklEVd1b_bLLGbVFSliwSuoJ1jvr9wDV3_F0f4pbXyC4Mrdjb_aU0i.CSUe38IKcb_5pupC3p.n3vlhsjgGFmMxH5jNeb7rYELR_.7sA8EXro0ubj1Vu78-&oauth_timestamp=1404900737>";
Map<String, Object> requestContext = ((BindingProvider) stub).getRequestContext();
requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,url);

And then I run the sample code, got an exception,

Exception in thread "main" com.sun.xml.internal.ws.client.ClientTransportException: The server sent HTTP status code 401: Authorization Required
    at com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.checkStatusCode(Unknown Source)
    at com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.createResponsePacket(Unknown Source)
    at com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.process(Unknown Source)
    at com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.processRequest(Unknown Source)
    at com.sun.xml.internal.ws.transport.DeferredTransportPipe.processRequest(Unknown Source)
    at com.sun.xml.internal.ws.api.pipe.Fiber.__doRun(Unknown Source)
    at com.sun.xml.internal.ws.api.pipe.Fiber._doRun(Unknown Source)
    at com.sun.xml.internal.ws.api.pipe.Fiber.doRun(Unknown Source)
    at com.sun.xml.internal.ws.api.pipe.Fiber.runSync(Unknown Source)
    at com.sun.xml.internal.ws.client.Stub.process(Unknown Source)
    at com.sun.xml.internal.ws.client.sei.SEIStub.doProcess(Unknown Source)
    at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(Unknown Source)
    at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(Unknown Source)
    at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(Unknown Source)
    at $Proxy35.getUserData(Unknown Source)
    at com.yahoo.mail.services.JaxWsSample.main(JaxWsSample.<java:129>)

by
1 Reply
  • I tested in Restful Client, and got the reason, the oauth_signature is incorrect. now I can access YMWS smoothly!

    0

Recent Posts

in Yahoo! Mail Web Services API