To set up OAuth 2.0 for your application, you have to register your application at Google Developers Console (for free). When you register, you will get client ID and client secret that will identify your application and enable OAuth authentication.
Steps to set up OAuth 2.0 for Gmail:
- In Google Developers Console, go to project list.
- If you have no project yet, you will be prompted to create a new one automatically. Otherwise, either select one of your existing projects or create a new one.
- In the menu, select API Manager.
- Select Gmail API and enable it.
- Select Credentials submenu.
- Click OAuth consent screen tab and configure the consent screen of your application.
- Click Credentials tab, hit Create credentials and select OAuth client ID.
- Select desired Application type for your project and enter information required (for desktop app select Other).
- Click Create button. You will see generated client ID and client secret in dialog window.
Now, you have enabled Gmail API for your project and you have client ID and client secret necessary for Gmail OAuth 2.0 authentication.
See also: How to authenticate to Gmail with Rebex Secure Mail using OAuth 2.0