How to get oauth token after logging in to Twitter?

After logging in to Twitter, I can print some useful data, such as username and user ID. However, the OAuth token is always zero. How do i get this? I need to send the OAuth token to my server so that it can verify that the user is really who he is talking to.

ACAccountStore* accountStore = [[ACAccountStore alloc] init]; ACAccountType* twitterType = [self.context.accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter]; [accountStore requestAccessToAccountsWithType:twitterType withCompletionHandler:^(BOOL isAllowed, NSError* error) { dispatch_sync(dispatch_get_main_queue(), ^(void) { if (isAllowed) { ACAccount* account = [[self.context.accountStore accountsWithAccountType:[self.context.accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter]] lastObject]; NSLog(@"username = %@", account.username); NSLog(@"user_id = %@", [[account valueForKey:@"properties"] valueForKey:@"user_id"]); // ouath token is always null NSLog(@"oauth token = %@", account.credential.oauthToken); } }); } ]; 

I think: "I need Reverse Auth , but this tutorial mysteriously left the code for" Step 1 ".

+2
source share
1 answer

You really need to use Reverse Auth.

I recently used the Sean Cook TWReverseAuth , and it worked very well. Just be careful to disable ARC for individual files in the Vendor directory.

0
source

Source: https://habr.com/ru/post/1492225/


All Articles