|
| 1 | +/* |
| 2 | + * Copyright 2019 Google LLC |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +// [START functions_firebase_auth] |
| 18 | +import com.google.cloud.functions.Context; |
| 19 | +import com.google.cloud.functions.RawBackgroundFunction; |
| 20 | +import com.google.gson.Gson; |
| 21 | +import com.google.gson.JsonObject; |
| 22 | +import java.util.logging.Logger; |
| 23 | + |
| 24 | +public class FirebaseAuth implements RawBackgroundFunction { |
| 25 | + |
| 26 | + // Use GSON (https://github.com/google/gson) to parse JSON content. |
| 27 | + private Gson gsonParser = new Gson(); |
| 28 | + |
| 29 | + private static final Logger LOGGER = Logger.getLogger(FirebaseAuth.class.getName()); |
| 30 | + |
| 31 | + @Override |
| 32 | + public void accept(String json, Context context) { |
| 33 | + JsonObject body = gsonParser.fromJson(json, JsonObject.class); |
| 34 | + LOGGER.info("Function triggered by event: " + json); |
| 35 | + } |
| 36 | +} |
| 37 | + |
| 38 | +// [END functions_firebase_auth] |
0 commit comments