I'm attempting to build an image service of sorts and am trying to
implement OAuth Echo to authorize users and get the username of the
person posting the picture.  Anyway, I seem to be having trouble and I
think I may be doing something wrong.  I keep getting the error "Could
not authenticate with OAuth".

What I am doing is:
- Taking the value passed in the header for "X-Verify-Credentials-
Authorization"
- URL encode the value
- Use it for my Authorization header in my request to
https://api.twitter.com/1/account/verify_credentials.json

I am attempting to do this using Twitter4J and the following code
illustrates what I'm doing:
TwitterFactory factory = new TwitterFactory();
                Twitter twitter = factory.getInstance(new
EchoAuthorization(request.getHeader("X-Verify-Credentials-
Authorization")));
                try {
                        System.out.println(twitter.verifyCredentials());
                }
                catch(Exception ex) {
                        ex.printStackTrace();
                }


-----

public class EchoAuthorization implements Authorization {
                private String authHeader;

                public String getAuthHeader() {
                        return authHeader;
                }
                public void setAuthHeader(String authHeader) {
                        this.authHeader = authHeader;
                }


                public EchoAuthorization (String authHeader) {
                        setAuthHeader(new URLEncoder().encode(authHeader));
                        System.out.println(getAuthHeader());
                }
                public boolean isEnabled() {
                        return true;
                }

                public String getAuthorizationHeader(HttpRequest arg0) {
                        System.out.println("auth header:"+getAuthHeader());
                        return getAuthHeader();
                }
        }

Any help would be greatly appreciated!  I've been stuck on this for a
while...

-- 
Twitter developer documentation and resources: http://dev.twitter.com/doc
API updates via Twitter: http://twitter.com/twitterapi
Issues/Enhancements Tracker: http://code.google.com/p/twitter-api/issues/list
Change your membership to this group: 
http://groups.google.com/group/twitter-development-talk

Reply via email to