Spin dynamics of exciton polaritons in microcavities