Use GoogleWebAuthorizationBroker for desktop.
GoogleWebAuthorizationBroker
For server-side web apps, use GoogleAuthorizationCodeFlow
GoogleAuthorizationCodeFlow