yahoo contacts

198 views
Skip to first unread message

Xiaobo Yang

unread,
Oct 12, 2009, 11:09:26 AM10/12/09
to dyupr...@googlegroups.com
Hi all,

I've tried to get yahoo contacts using OAuth with this very helpful project. I followed the example on the wiki which works for Google for me. I've got the access token and my Yahoo GUID successfully. The problem happened when I tried to get my yahoo contacts, I always got the error message below. Any idea what caused this problem?

Many thanks,
Xiaobo

<yahoo:error xml:lang="en-US">
<yahoo:description>
Please provide valid credentials. OAuth oauth_problem="unable_to_determine_oauth_type", realm="yahooapis.com"
</yahoo:description>
</yahoo:error>
<!--
 ws103.socdir.ac4.yahoo.com uncompressed/chunked Mon Oct 12 07:54:31 PDT 2009
-->

David Yu

unread,
Oct 13, 2009, 2:35:23 AM10/13/09
to dyupr...@googlegroups.com
It likely a bug on yahoo's part during the verification of the access_token.
I've made a post on their forums.  See http://developer.yahoo.net/forum/index.php?showtopic=2891

Cheers

Xiaobo

unread,
Oct 13, 2009, 10:37:53 AM10/13/09
to dyuproject
OK. I've found out the workaround by appending the parameters to the
GET URL. - Regards, Xiaobo

On Oct 13, 7:35 am, David Yu <david.yu....@gmail.com> wrote:
> It likely a bug on yahoo's part during the verification of the access_token.
> I've made a post on their forums.  Seehttp://developer.yahoo.net/forum/index.php?showtopic=2891
>
> Cheers

David Yu

unread,
Oct 13, 2009, 12:20:29 PM10/13/09
to dyupr...@googlegroups.com
Cool.
So for anyone who encounters the same problem, the solution is:

    // VIA normal HTTP GET parameters
    public static Response serviceGET(String serviceUrl, ConsumerContext context, Endpoint ep,
            Token token, HttpServletRequest request, HttpServletResponse response)
            throws IOException
    {
        HttpConnector connector = context.getHttpConnector();
        UrlEncodedParameterMap params = new UrlEncodedParameterMap(serviceUrl);
        context.getNonceAndTimestamp().put(params, token.getCk());
        params.put(Constants.OAUTH_CONSUMER_KEY, ep.getConsumerKey());
        params.put(Constants.OAUTH_TOKEN, token.getKey());
        params.put(Constants.OAUTH_SIGNATURE_METHOD, ep.getSignature().getMethod());
        String sig = ep.getSignature().sign(ep.getConsumerSecret(), token.getSecret(),
                Signature.getBase(params, "GET"));
        params.put(Constants.OAUTH_SIGNATURE, sig);
        return connector.doGET(params.toStringRFC3986(), (Map<?,?>)null);
    }

    // VIA HTTP GET but the oauth parameters are transported via the "Authorization" header.
    // this does not work on yahoo ... a bug they need to fix.   
    /*public static Response serviceGET(String serviceUrl, ConsumerContext context, Endpoint ep,
            Token token, HttpServletRequest request, HttpServletResponse response)
            throws IOException
    {
        HttpConnector connector = context.getHttpConnector();
        UrlEncodedParameterMap params = new UrlEncodedParameterMap(serviceUrl);
        context.getNonceAndTimestamp().put(params, token.getCk());
        Parameter authorization = new Parameter("Authorization",
                HttpAuthTransport.getAuthHeaderValue(params, ep, token,
                context.getNonceAndTimestamp(),  ep.getSignature()));
        return connector.doGET(params.getUrl(), authorization);
       
    }*/

Cheers
Reply all
Reply to author
Forward
0 new messages