  The inclusive J/$\psi$ elliptic ($v_2$) and triangular ($v_3$) flow
coefficients measured at forward rapidity (2.5 $<y<$ 4) and the $v_2$ measured
at midrapidity ($|y|<$ 0.9) in Pb-Pb collisions at $\sqrt{s_{\rm NN}}$ = 5.02
TeV using the ALICE detector at the LHC are reported. The entire Pb-Pb data
sample collected during Run 2 is employed, amounting to an integrated
luminosity of 750 $\mu$b$^{-1}$ at forward rapidity and 93 $\mu$b$^{-1}$ at
midrapidity. The results are obtained using the scalar product method and are
reported as a function of transverse momentum $p_{\rm T}$ and collision
centrality. At midrapidity, the J/$\psi$ $v_2$ is in agreement with the forward
rapidity measurement. The centrality averaged results indicate a positive
J/$\psi$ $v_3$ with a significance of more than 5$\sigma$ at forward rapidity
in the $p_{\rm T}$ range $2<p_{\rm T}<5$ GeV/$c$. The forward rapidity $v_2$,
$v_3$, and $v_3$/$v_2$ results at low and intermediate $p_{\rm T}$ ($p_{\rm T}
\lesssim 8$ GeV/$c$) exhibit a mass hierarchy when compared to pions and D
mesons, while converging into a species-independent curve at higher $p_{\rm
T}$. At low and intermediate $p_{\rm T}$, the results could be interpreted in
terms of a later thermalization of charm quarks compared to light quarks, while
at high $p_{\rm T}$, path-length dependent effects seem to dominate. The
J/$\psi$ $v_2$ measurements are further compared to a microscopic transport
model calculation. Using a simplified extension of the quark scaling approach
involving both light and charm quark flow components, it is shown that the
D-meson $v_{\rm n}$ measurements can be described based on those for charged
pions and J/$\psi$ flow.
