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_token
email
first_name
last_name
refresh_token
expires_at
どの API リクエストを行う必要がありますか?