Search code examples
ruby-on-railsoauthyahoo-api

What rails field type i should use for a aouth token?


I don't know what type i should use in the migration file for a outh token i get from yahoo, i should a :text type column or there is a especial one for this?

class AddColumnsToUsers < ActiveRecord::Migration
  def change
    add_column :users, :provider, :string
    add_column :users, :uid, :string
    add_column :users, :first_name, :string
    add_column :users, :last_name, :string
    # the tokens
    add_column :users, :oauth_token, :string
    add_column :users, :oauth_token_secret, :string
  end
end

Solution

  • There seems to be no upper limit on size of OAuth Token.

    If we take Facebook as an example, it's documentation states:

    Please use a variable length data type without a specific maximum size to store access tokens.

    This Quora feed might also be interesting for you.

    Also see this comment from Doorkeeper gem source code:

    If you use a custom token generator you may need to change this column from string to text, so that it accepts tokens larger than 255 characters.

    So my suggestion is to use TEXT field, instead of STRING.