How to do it...

Create a new project in Android Studio, which can be named AuthCodeApp, and perform the following steps (when creating the application make sure to automatically create an empty activity named MainActivity). The complete source code for this recipe can be download at https://github.com/PacktPublishing/OAuth-2.0-Cookbook/tree/master/Chapter07/AuthCodeApp.

  1. As we need to interact with an API through HTTP requests, let's add retrofit2 as the dependency for our project. The retrofit2 is a great library that helps when interacting with REST APIs. To add retrofit2 to our project, open the application build.gradle file and add the following content within the dependencies declaration:
compile 'com.squareup.retrofit2:retrofit:2.3.0' ...

Get OAuth 2.0 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.