@@ -772,3 +772,70 @@ func getIDTokenFromBody(r *http.Request) (string, error) {
772
772
err = json .Unmarshal (b , & parsedBody )
773
773
return parsedBody .IDToken , err
774
774
}
775
+
776
+ func newActionCodeSettings () * auth.ActionCodeSettings {
777
+ // [START init_action_code_settings]
778
+ actionCodeSettings := & auth.ActionCodeSettings {
779
+ URL : "https://www.example.com/checkout?cartId=1234" ,
780
+ HandleCodeInApp : true ,
781
+ IOSBundleID : "com.example.ios" ,
782
+ AndroidPackageName : "com.example.android" ,
783
+ AndroidInstallApp : true ,
784
+ AndroidMinimumVersion : "12" ,
785
+ DynamicLinkDomain : "coolapp.page.link" ,
786
+ }
787
+ // [END init_action_code_settings]
788
+ return actionCodeSettings
789
+ }
790
+
791
+ func generatePasswordResetLink (ctx context.Context , client * auth.Client ) {
792
+ actionCodeSettings := newActionCodeSettings ()
793
+ displayName := "Example User"
794
+ // [START password_reset_link]
795
+ email := "user@example.com"
796
+ link , err := client .PasswordResetLinkWithSettings (ctx , email , actionCodeSettings )
797
+ if err != nil {
798
+ log .Fatalf ("error generating email link: %v\n " , err )
799
+ }
800
+
801
+ // Construct password reset template, embed the link and send
802
+ // using custom SMTP server.
803
+ sendCustomEmail (email , displayName , link )
804
+ // [END password_reset_link]
805
+ }
806
+
807
+ func generateEmailVerificationLink (ctx context.Context , client * auth.Client ) {
808
+ actionCodeSettings := newActionCodeSettings ()
809
+ displayName := "Example User"
810
+ // [START email_verification_link]
811
+ email := "user@example.com"
812
+ link , err := client .EmailVerificationLinkWithSettings (ctx , email , actionCodeSettings )
813
+ if err != nil {
814
+ log .Fatalf ("error generating email link: %v\n " , err )
815
+ }
816
+
817
+ // Construct email verification template, embed the link and send
818
+ // using custom SMTP server.
819
+ sendCustomEmail (email , displayName , link )
820
+ // [END email_verification_link]
821
+ }
822
+
823
+ func generateEmailSignInLink (ctx context.Context , client * auth.Client ) {
824
+ actionCodeSettings := newActionCodeSettings ()
825
+ displayName := "Example User"
826
+ // [START sign_in_with_email_link]
827
+ email := "user@example.com"
828
+ link , err := client .EmailSignInLink (ctx , email , actionCodeSettings )
829
+ if err != nil {
830
+ log .Fatalf ("error generating email link: %v\n " , err )
831
+ }
832
+
833
+ // Construct sign-in with email link template, embed the link and send
834
+ // using custom SMTP server.
835
+ sendCustomEmail (email , displayName , link )
836
+ // [END sign_in_with_email_link]
837
+ }
838
+
839
+ // Place holder function to make the compiler happy. This is referenced by all email action
840
+ // link snippets.
841
+ func sendCustomEmail (email , displayName , link string ) {}
0 commit comments