Hi Gabe,
For OAuth Echo you should be sending the value in:
X-Verify-Credentials-Authorization
to the URL given in:
X-Auth-Service-Provider
You need to use X-Auth-Service-Provider to ensure you are sending the
request to the same endpoint that was used to create the signature. This URL
could any of these:
http://api.twitter.com/1/account/verify_credentials.json
https://api.twitter.com/1/account/verify_credentials.json
http://api.twitter.com/1/account/verify_credentials.xml
https://api.twitter.com/1/account/verify_credentials.xml
Also, the error "Could not authenticate with OAuth" indicates there is a
problem with your consumer and/or user values. Double check the tokens and
secrets that are being used are correct.
Best
@themattharris
Developer Advocate, Twitter
http://twitter.com/themattharris
On Mon, Jan 3, 2011 at 5:19 PM, Gabe <[email protected]> wrote:
> 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
>
--
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