Unsupported Authentication
HackerGaucho opened this issue · 2 comments
HackerGaucho commented
What are you attempting to do
Add rules to Filtered Stream
Expected behavior
Return a array with the rules
Actual behavior
Return a 403
object(stdClass)#4 (4) {
["title"]=>
string(26) "Unsupported Authentication"
["detail"]=>
string(141) "Authenticating with OAuth 1.0a User Context is forbidden for this endpoint. Supported authentication types are [OAuth 2.0 Application-Only]."
["type"]=>
string(61) "https://api.twitter.com/2/problems/unsupported-authentication"
["status"]=>
int(403)
}
Code example
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $access_token, $access_token_secret);
$connection->setApiVersion('2');
$rules_arr=[
'add' =>
[
'value' => 'term1',
],
[
'value' => 'term2',
],
];
$result = $connection->post('tweets/search/stream/rules/',$rules_arr,true);
var_dump($result);
Versions:
- TwitterOAuth: [e.g. v4.0.1]
- PHP: v [e.g. v8.1.11]
Additional context
Add any other context about the problem here.
abraham commented
I think you need to get app app token like in the testOauth2Token
test and use it like in the testOauth2BearerToken
test.
haleyngonadi commented
Thanks, @abraham! I was able to get it working with your tip!
$connection = new TwitterOAuth(
config('twitter.consumer_key'),
config('twitter.consumer_secret')
);
$request_token = $connection->oauth2('oauth2/token', ['grant_type' => 'client_credentials']);
$connection->setBearer($request_token->access_token);