Guest User

Untitled

a guest
Jul 18th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. package main
  2.  
  3. import (
  4. "context"
  5. "encoding/json"
  6. "fmt"
  7. "os"
  8. "path"
  9.  
  10. "firebase.google.com/go"
  11. "google.golang.org/api/option"
  12. )
  13.  
  14. func main() {
  15. app, err := firebase.NewApp(context.Background(), &firebase.Config{
  16. ProjectID: "<PROJECT_ID>",
  17. }, option.WithCredentialsFile("<CREDENTIAL_FILE_PATH>"))
  18. if err != nil {
  19. panic(err)
  20. }
  21.  
  22. cli, err := app.Auth(context.Background())
  23. if err != nil {
  24. panic(err)
  25. }
  26.  
  27. rec, err := cli.GetUser(context.Background(), "<UID>")
  28. if err != nil {
  29. panic(err)
  30. }
  31.  
  32. recJSON, err := json.MarshalIndent(rec, "", " ")
  33. if err != nil {
  34. panic(err)
  35. }
  36.  
  37. fmt.Printf("%s\n", recJSON)
  38.  
  39. if err := cli.SetCustomUserClaims(context.Background(), "<UID>", map[string]interface{}{
  40. "this is sample": "hogehoge fugafuga",
  41. }); err != nil {
  42. panic(err)
  43. }
  44. }
Add Comment
Please, Sign In to add comment