I have a single page app that integrates with other services such as Dropbox and LinkedIn. Dropbox, for instance, has great API and I got the authentication working by opening Dropbox's authentication link in another window. Once the user authenticates, I ask them to close that new window to return to my app.
Clearly this is suboptimal as it takes the user away from my app, and even more cumbersome on tablets.
How would I do the authentication within the app, such is in a lightbox or a modal form?
Note that the integration itself happens server-side not client side. Presently, the Dropbox authentication page has a call back page that signals to my server that authentication was successful, which I store in the user's table in the database for future use.
Note: The bounty comment should read: A code sample is highly desired but not required.