Android SDK Tutorial 2 – Authentication and Authorization
Tags: android, tutorial, applozic
Published: 2021-06-16 20:19:30

##Introduction

<!-- wp:paragraph -->
<p>This tutorial is Part 2 of a multi-part series covering Applozic Android SDK integration into an Android app. </p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Our goal is to complete the following steps in this tutorial:</p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><li>Learn how to generate an access token for your application</li><li>Create a User Object</li><li>Register/Login the user</li><li>Update password for user</li><li>Update User Details</li></ol>
<!-- /wp:list -->

<!-- wp:heading -->
<h2>What are Authentication and Authorization?</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>In the simplest terms, we can classify them as: </p>
<!-- /wp:paragraph -->

<!-- wp:list -->
<ul><li><strong>Authentication</strong>: Proving your identity to an entity</li><li><strong>Authorization</strong>: The ability to interact with an entity</li></ul>
<!-- /wp:list -->

<!-- wp:image {"id":2113,"width":768,"height":413,"sizeSlug":"large"} -->
<figure class="wp-block-image size-large is-resized"><img src="https://www.applozic.com/blog/wp-content/uploads/2021/06/Android-SDK-Tutorial-2-Authentication-and-Authorization-Image-02-02-02-1024x551.png" alt="" class="wp-image-2113" width="768" height="413"/><figcaption>Authentication vs Authorization</figcaption></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>Authentication and authorization with APIs have a lot of value, some of them are:</p>
<!-- /wp:paragraph -->

<!-- wp:list -->
<ul><li>Authenticate that calls to the API are done by registered users only</li><li>Maintain a record to track which user is making the requests</li><li>Track the total usage of the API calls across users and applications</li><li>Notify any user who exceeds their&nbsp;plan limit</li><li>Apply different permission levels to different users</li></ul>
<!-- /wp:list -->

<!-- wp:paragraph -->
<p>Now that we have learnt the need for authentication and authorization, let's get started with the first step in this tutorial.</p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2>Generating Access Token</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Access Token URL (Authentication URL) is required to ensure your platforms are safe from unauthorized access.&nbsp;This can be configured by the Application admin in Applozic Dashboard for authenticating users from your backend server.</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":3} -->
<h3>Setup Access Token URL in Dashboard</h3>
<!-- /wp:heading -->

<!-- wp:list {"ordered":true} -->
<ol><li>Login to&nbsp;<a rel="noreferrer noopener" href="https://dashboard.applozic.com/admin/dashboard.html#" target="_blank">Applozic Dashboard</a></li><li>Go to Dashboard. Select Application -&gt; Action -&gt; Edit -&gt; Security.</li><li>Enter your server URL for authentication in the "Access Token URL" field.</li></ol>
<!-- /wp:list -->

<!-- wp:image {"id":2104,"sizeSlug":"large"} -->
<figure class="wp-block-image size-large"><img src="https://www.applozic.com/blog/wp-content/uploads/2021/06/image-15-1024x348.png" alt="" class="wp-image-2104"/><figcaption>Application screen in Dashboard</figcaption></figure>
<!-- /wp:image -->

<!-- wp:image {"id":2105,"sizeSlug":"large"} -->
<figure class="wp-block-image size-large"><img src="https://www.applozic.com/blog/wp-content/uploads/2021/06/image-16-1024x279.png" alt="" class="wp-image-2105"/><figcaption>Security Tab in Edit Application settings</figcaption></figure>
<!-- /wp:image -->

<!-- wp:code -->
<pre class="wp-block-code"><code>Note: Configured Access Token URL should accept POST request with data passed as request body in form-url-encoded.</code></pre>
<!-- /wp:code -->

<!-- wp:paragraph -->
<p>You can now use an API testing tool like Postman to verify your access. </p>
<!-- /wp:paragraph -->

##Continue this Tutorial on Applozic Blog!
We have the detailed tutorial with code snippets available on [our blog](https://www.applozic.com/blog/applozic-android-sdk-tutorial-2/) for you to continue with your integration!

[Click here](https://www.applozic.com/blog/applozic-android-sdk-tutorial-2/) to learn how to:
* Create a User Object
* Register/Login the user
* Update password and User details


Please leave your feedback and doubts in the comments below!