Closed GirlBoomer closed 9 months ago
I guess it's because the two requests use the same oauth_nonce
, please click the Random button next to the input box to generate a new oauth_nonce
The oauth_nonce parameter is a unique token your application should generate for each unique request. Twitter will use this value to determine whether a request has been submitted multiple times.
Even when generated fresh timestamp and nonce it will not authorize. I have updated example code to represent that this is the case.
It's weird, because it works in node.js
console.log(await (await fetch('https://api.twitter.com/graphql/CO4_gU4G_MRREoqfiTh6Hg/UserByRestId?variables=%7B%22withSuperFollowsUserFields%22%3Atrue%2C%22withSafetyModeUserFields%22%3Atrue%2C%22userId%22%3A%22783214%22%7D&features=%7B%22hidden_profile_likes_enabled%22%3Atrue%2C%22hidden_profile_subscriptions_enabled%22%3Atrue%2C%22responsive_web_graphql_exclude_directive_enabled%22%3Atrue%2C%22verified_phone_label_enabled%22%3Afalse%2C%22highlights_tweets_tab_ui_enabled%22%3Atrue%2C%22responsive_web_twitter_article_notes_tab_enabled%22%3Afalse%2C%22creator_subscriptions_tweet_preview_api_enabled%22%3Atrue%2C%22responsive_web_graphql_skip_user_profile_image_extensions_enabled%22%3Afalse%2C%22responsive_web_graphql_timeline_navigation_enabled%22%3Atrue%7D', {
headers: {
authorization: 'OAuth realm="http://api.twitter.com/", oauth_version="1.0", oauth_token="1749847962413617152-wZGYi1AGGPFWpq5mxU767lMKn6WrCD", oauth_nonce="YzI3YzQxMjBjYzlkNDE0OTliNGMxM2YxNDEzZWEwMDU", oauth_timestamp="1706110880", oauth_signature="9miWy0rpZbYibURJTM4zKBasPVc%3D", oauth_consumer_key="3nVuSoBZnx6U4vzUxf5w", oauth_signature_method="HMAC-SHA1"'
}
})).text())
// response
// {"data":{"user":{"result":{"__typename":"User","id":"VXNlcjo3ODMyMTQ=","rest_id":"783214","affiliates_highlighted_label":{},"has_graduated_access":true,"is_blue_verified":true,"profile_image_shape":"Square","legacy":{"can_dm":false,"can_media_tag":true,"created_at":"Tue Feb 20 14:35:54 +0000 2007","default_profile":false,"default_profile_image":false,"description":"what's happening?!","entities":{"description":{"urls":[]},"url":{"urls":[{"display_url":"about.x.com","expanded_url":"https://about.x.com/","url":"https://t.co/bGcvaMApJO","indices":[0,23]}]}},"fast_followers_count":0,"favourites_count":5908,"followers_count":67438322,"friends_count":0,"has_custom_timelines":true,"is_translator":false,"listed_count":88672,"location":"everywhere","media_count":2413,"name":"X","normal_followers_count":67438322,"pinned_tweet_ids_str":[],"possibly_sensitive":false,"profile_banner_url":"https://pbs.twimg.com/profile_banners/783214/1690175171","profile_image_url_https":"https://pbs.twimg.com/profile_images/1683899100922511378/5lY42eHs_normal.jpg","profile_interstitial_type":"","screen_name":"X","statuses_count":15124,"translator_type":"regular","url":"https://t.co/bGcvaMApJO","verified":false,"verified_type":"Business","want_retweets":false,"withheld_in_countries":[]},"smart_blocked_by":false,"smart_blocking":false,"business_account":{"affiliates_count":100},"highlights_info":{"can_highlight_tweets":true,"highlighted_tweets":"3"},"creator_subscriptions_count":0,"has_hidden_likes_on_profile":false,"has_hidden_subscriptions_on_profile":false}}}}
I don't know how to solve this problem. But there should be no problem with the signature builder of that page.
This has something to do with aiohttp, I am not going to investigate. Problem was solved by switching to different client.
你好 BANKA, I am pretty sure that your signature builder (https://banka2017.github.io/twitter-monitor/apps/online_tools/oauth_signature_builder.html) generates wrong signatures when using GraphQL links.
As a a result, response for restful will return expected info in json as expexcted:
where GraphQL will return: