FirebaseController

PHOTO EMBED

Fri May 05 2023 09:17:55 GMT+0000 (Coordinated Universal Time)

Saved by @namnt

package com.example.loginbysocial.controller;

import com.example.loginbysocial.entity.Profile;
import com.example.loginbysocial.service.FirebaseService;
import com.google.firebase.auth.FirebaseAuthException;
import com.google.firebase.auth.FirebaseToken;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

@RestController
@RequestMapping("/auth")
public class FirebaseController {
        @Autowired
        private FirebaseService firebaseService;
        @PostMapping("/firebaseInfo")
        public Profile authenticateWithFirebase(@RequestParam String accessToken) throws FirebaseAuthException, IOException {
            FirebaseToken firebaseToken= firebaseService.authenticateUser(accessToken);
            Profile profile= firebaseService.getInfo(firebaseToken);
            return profile;
        }
}
content_copyCOPY