The usual oAuth flow is covered here:
One redirect One cURL request after the user comes back to your website.