How to enable auto sync on WiFi only I want to have Auto Sync on my android always enabled, but I want it to only work while on wifi. I don't want to enable/disable it everytime I am going from wifi to mobile data. So is there a way to configure it to only be executed while on wifi?

To clarify. I have restricted some apps from background data usage while on mobile networks. But what I want is accounts auto sync to be restricted.

Is there a built in way to do this without using any third party apps?
There is no way to do this without the use of third party apps. You can use Tasker to automate your phone. You can add a task that enables auto sync when you're on WiFi.

 The stock android doesn't provide any option that says "Auto sync only on WiFi". only way to do this is through third party apps. By the way, there are other automation apps also on the Google Play. You can go and check them out.

 Another way to do this is to use custom roms. Many custom ROMs have built in modules or profiles to set while you're on your favourite WiFi network. Cyanogenmod is a good option to go with. I don't remember exactly but i think there is an xposed module that does this job. Feel free to check them out. Hope this helps!!

Link to Tasker app