How To Create Access Tokens From SharePoint Online?

An access key token is used to authenticate your access to Microsoft translator API. It provides secure access to Microsoft Translator API.

Here we can set up OAuth for SharePoint Online to authorize REST API calls to the SharePoint site to retrieve and manipulate the site data.

Below are the detailed steps,

Step 1

Register an app in SharePoint.

Step 2

Navigate to https://your_site_name.com/_layouts/15/appregnew.aspx 

Step 3

Click Generate for Client Id and Client Secret.

Step 4

It will ask to fill in Client Id, Client Secret, Title, App Domain, and Redirect URI.

Note. The Client's secret key validity is one year since the creation of your Apps. We will use Powershell to update the key.

Step 5

Generate a new ClientSecret for this clientID. It uses the same clientId as set in the above step. The new ClientSecret is valid for 3 years.

$bytes = New-Object Byte[] 32  
$rand = [System.Security.Cryptography.RandomNumberGenerator]::Create()  
$rand.GetBytes($bytes)  
$rand.Dispose()  
$newClientSecret = [System.Convert]::ToBase64String($bytes)  
$dtStart = [System.DateTime]::Now  
$dtEnd = $dtStart.AddYears(3)  
New-MsolServicePrincipalCredential -AppPrincipalId $clientId -Type Symmetric -Usage Sign -Value $newClientSecret -StartDate $dtStart  -EndDate $dtEnd  
New-MsolServicePrincipalCredential -AppPrincipalId $clientId -Type Symmetric -Usage Verify -Value $newClientSecret   -StartDate $dtStart  -EndDate $dtEnd  
New-MsolServicePrincipalCredential -AppPrincipalId $clientId -Type Password -Usage Verify -Value $newClientSecret   -StartDate $dtStart  -EndDate $dtEnd  
$newClientSecret

Step 6

Copy the output of $newClientSecret.

Step 7

Replace the Web.config with this ClientId and ClientSecret. You don't need SecondaryClientSecret app settings.

Step 8

Wait at least 24 hours to propagate ClientSecret to SharePoint Office (SPO)

Create a Package for your Client

Step 1

Open SharePoint Online.

Step 2

Put the URL " https://your_site_name.com/_layouts/15/appregnew.aspx ".

How To Create Access Token From SharePoint Online?

Fill in the details,

How To Create Access Token From SharePoint Online

After that, you have to click Create a button to get a confirmation screen.

How To Create Access Token From SharePoint Online

Summary

Here are the steps for creating the Access key token in SharePoint online and extending the Client secret using the Powershell command.