0

I try to do the same than : use facebook iOS client authorization on own to server, but with twitter.

I use SSO with Twitter Kit (Fabric) on iOS. I manage to sign in and get the authToken and authTokenSecret of the user. Then, I would like to send these to my server, so that I can retrieve the corresponding user in my own database.

I know I have to use a OAuth client. Working with Rails, I use the twitter gem.

But when I try to do :

client = Twitter::REST::Client.new do |config|
  config.consumer_key        = "YOUR_CONSUMER_KEY" #I added my rail app at twitter dev center
  config.consumer_secret     = "YOUR_CONSUMER_SECRET" #idem
  config.access_token        = "YOUR_ACCESS_TOKEN" #from the ios app
  config.access_token_secret = "YOUR_ACCESS_SECRET" #from the ios app
end

I keep having a 401 Twitter::Error::Unauthorized, Could not authenticate you. And I'm stuck. Did I do something wrong?

Is this because the ios app that fetched the first access tokens is different than the rails app (and so the consumer_key/secret of the rails app won't work)?

Thank you very much

Jery

PS: I have been stuck for several days, so if you have an answer, you will save my week ;)

Community
  • 1
  • 1
darksider
  • 1,030
  • 2
  • 14
  • 20

1 Answers1

0

To answer my own question: The process described in the question works. The only thing that I corrected is the consumer_key and consumer_secret. Since the access_token/secret of the user were generated by the iOS SSO, the consumer_key and consumer_secret needed were not the ones of your rails app, but the one of your iOS app (that you can find in Fabric admin).

Then, the twitter client in your rails app can send back all relevant information about the user in your database.

darksider
  • 1,030
  • 2
  • 14
  • 20