1

Rails アプリと Google を統合するための API を開発しています。

私はクライアントからのみ受け取ります:


{
  provider:     'google_oauth2',
  user_id:      'USER_ID',
  access_token: 'ACCESS_TOKEN'
}

ただし、ユーザーが登録されていない場合などは、ユーザーを作成してデータベースに保存する必要があります。モデルがuserあり、authentication(ユーザーには多くの認証があります):


class User
  validates :first_name, :last_name, :email, 
            presense: true 

  has_many :providers
endd

class Authentication
  validates :provider, :user_id, :access_token, :refresh_token, :expires_at, 
            presense: true

  belongs_to :user
end

Google アプリは既に作成されており、すべての権限が正しく設定されています。

問題:

認証を使用してユーザーをDBに保存するには、すべてのフィールドが必要です。

質問:

と がある場合、追加のフィールドを取得するにはどうすればproviderよいですか: 、、、user_idおよび。access_tokenemailfirst_namelast_namerefresh_tokenexpires_at

どの API リクエストを行う必要がありますか?

4

0 に答える 0