Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't post tweet without elevated account (using the V2 API) #421

Open
shai-almog opened this issue Oct 31, 2022 · 7 comments
Open

Can't post tweet without elevated account (using the V2 API) #421

shai-almog opened this issue Oct 31, 2022 · 7 comments

Comments

@shai-almog
Copy link

I'm trying to post a tweet without the elevated permissions and getting an error since 1.x isn't supported. Looking at the code I see this line:
https://github.com/redouane59/twittered/blob/develop/src/main/java/io/github/redouane59/twitter/TwitterClient.java#L803

I tried to change getRequestHelper() instead of getRequestHelperV1(). But this won't work since postRequestWithBodyJson is V1 specific so I guess we need something different here.

I tried doing something similar to:

  public Tweet postTweet(final TweetParameters tweetParameters) {
    String url  = getUrlHelper().getPostTweetUrl();
    String body = JsonHelper.toJson(tweetParameters);
    if(isV1()) {
      return getRequestHelperV1()
              .postRequestWithBodyJson(url, new HashMap<>(), body, TweetV2.class)
              .orElseThrow(NoSuchElementException::new);
    } else {
      return getRequestHelperV2().postRequest(url, body, TweetV2.class).orElseThrow(NoSuchElementException::new);
    }
  }

But it seems wrong.

It seems a bit unclear when V1 is used and when V2 is used. I'd be happy to submit a PR to the readme if I understood that logic.

@redouane59
Copy link
Owner

Hey @shai-almog , if I remember well, the getRequestHelperV2() is using oAuth2 (with token), and V1 is not.

What do you mean exactly by without elevated permission ? You want to use the credentials of another user than your own account ?

@shai-almog
Copy link
Author

No. I mean this
Screen Shot 2022-10-31 at 21 17 24

@redouane59
Copy link
Owner

Oh OK, so you mean that with an essential account the method is not working right ?

@shai-almog
Copy link
Author

Yes.

@redouane59
Copy link
Owner

redouane59 commented Oct 31, 2022

It looks like the essential account doesn't support the oAuth 1.0a

image

Maybe we should implement something related to OAuth 2.0 with PKCE. Honestly I'm not expert about that, if you think that you could develop it, I can try to help you.

You can also check the Oauth2PKCETest class.

@shai-almog
Copy link
Author

I worked with OAuth but I can't say I'm deeply familiar with the nuances. I'll try to look into it.

@redouane59
Copy link
Owner

Ok feel free to submit a pull request :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants