Twitter API application only mode authentication

2020-05-06 12:57发布

I've tried to integrate the STTwitter framework (Github project) for interacting with the Twitter API 1.1.

After I've create an app in my dev account, I've used the OAuth credentials for application only mode authentication. Anyway, I get the following error and I don't know how to fix it: Error Domain=STTwitterTwitterErrorDomain Code=220 "Your credentials do not allow access to this resource"

STTwitterAPI *twitter = [STTwitterAPI twitterAPIWithOAuthConsumerKey:@"XXX"
                                             consumerSecret:@"XXX"];
[twitter verifyCredentialsWithSuccessBlock:^(NSString *bearerToken) {

    NSLog(@"Access granted with %@", bearerToken);


} errorBlock:^(NSError *error) {
    NSLog(@"-- error %@", error);
}];

Does anyone have a clue how to fix it?

2条回答
太酷不给撩
2楼-- · 2020-05-06 13:52

This is because you didn't use the right STTwitterAPI constructor.

Use [STTwitterAPI twitterAPIAppOnlyWithConsumerKey:consumerSecret:] instead and your example will work fine.

查看更多
姐就是有狂的资本
3楼-- · 2020-05-06 13:52

I got the same problem. However it was caused by the Twitter account on the device not being setup properly - the password field was empty. After I've fixed that I could communicate with Twitter without a problem!

查看更多
登录 后发表回答