How to follow a channel on behalf of a user?

Thank for you answer Six. I have read the documentation but one thing I dont understand is: I have a method called handleTwitchCallback. This method only does is to handle the callback from Twitch but what Im trying to do is: I would like to have an Ajax request on behalf of the user to follow channel x. How am I going to get the code for beeing able to create the access token?

Here is a mock up of my methods:

function redirectToTwitch()
function handleTwichCallback() -> this method just register the user in my webapp and store the twitch id
function followChannel() -> I would like this method to perform the follow action on behalf of the user

My problem here is: I cant seem to redirect the user to the Twitch application because it is an AJax call. Any ideas?

Once again, thank you for your time and the answer