Well it comes down to trust.

You or your friend will be the Host,
example- On your XB1 you will have your friends profile saved on your console.

If you have a Gold membership, he/she will automatically have Gold as well ( You can also deactivate this).

On your friends console, he/she must go to their console user setting where they must set their XBOX to not being their home console.

This can be found when you go to Settings and on the left hand side will be colored tabs,the top being your gamer profile, the bottom one being your Xbox Home settings, you will select the last one.

The you will see an option to set you console to MY HOME or NOT MY HOME.

Your friend MUST choose NOT MY HOME.

What this will do is make your console his home console, this will mean that, whatever games you have digitally on your console, they will be able to download and play,but only as long as your console is set as his home console.
If the settings are changed,your friend will not be able to play any of the games as Microsoft will ask him to purchase the game.

You will then be able to play the same games at the same time together, or whenever either of you want to play.

Remember it's about trust as that persons details(bank account will be on your console, if he purchases digital games) and their gamer profile is accessible.

This can ONLY happen between two consoles though.

Hope this helps.