Drinking fresh coffee is, of course, the best. Roasting coffee pulls flavorful coffee oils toward the surface and caramelizes sugars. Unfortunately, those same coffee oils are highly volatile and prone to oxidation and rancidity, which degrade flavor and aroma leading to stale coffee.
The adversaries of roasted coffee are: moisture, heat, light and time. If you see oil on your coffee (as in the case of dark roasts), it is highly prone to rancidity and the staling effects of time and oxygen.
If you are going to drink your coffee over the course of 2 – 3 weeks, seal in a mason jar and place it in the cupboard.
If you absolutely, positively need to wait longer than 3 weeks to consume, place in an airtight container (i.e. the still-sealed bag your coffee arrived in), remove as much air from the container as possible and place in the freezer. This helps to keep the beans fresh until you’re ready to drink.