Sorry if it sounds silly but I am thinking if there is a way to find out if a line is a tanget of a curve?

Say given a curve of , how do I determine if any one given line is a tangent of this curve or not? The line can be y=x+7 or y=-2x-4, etc. And if it is a tangent of the curve, how do I find the points that this line is tangent to the curve?

I am thinking that I differentiate the equation of the curve to have dy/dx. Then I can get the gradient at any one point of the curve to compare with a line. But this isn't enough because same gradient doesn't mean is a tangent to the curve. And how I find the points which the line is tangent to the curve without any given points at all?

Thanks for any help!