I\'m a little confused as to how I get the Twitter OAuth Token using the iOS Social Framework. Assuming I have a Facebook and Twitter account setup on iOS6, and I can get the AC
Actually if your only concern is to retrieve the OAuth token, there is a very simple way to access this using the Social
Framework.
Inside the documentation lies a method called:
func preparedURLRequest() -> NSURLRequest!
Return Value An OAuth-compatible NSURLRequest object that allows an app to act on behalf of the user while keeping the user’s password private. The NSURLRequest is signed as OAuth1 by default, or OAuth2 by adding the appropriate token based on the user’s account.
Discussion Use this method to modify your request before sending. By setting the account correctly, this method will automatically add any necessary tokens.
So you can just simply create a signed SLRequest
like this:
let accounts = self.accountStore.accountsWithAccountType(type)
let request = SLRequest(
forServiceType: SLServiceTypeTwitter,
requestMethod: .GET,
URL: NSURL(string: "https://api.twitter.com/1.1/account/verify_credentials.json"),
parameters: ["include_entities": true])
request.account = accounts?.first as? ACAccount
and now simply access the request.preparedURLRequest().allHTTPHeaderFields()
And you'll see the oauth_token
in it.
However you won't have the Secret token (because it's used to generate the oauth_signature
as per twitter documentation) which makes this pretty useless for server side management.