pyastouch
pyastouch

Reputation: 11

Access token from Azure App has 6k+ chars & unable to save encrypted in SQL Server due to length restriction

To authenticate mail server from an application we use OAuth authentication. Application uses Java mail API for SMTP mail communication. We create an app in Azure and use its client ID and client secret to generate access token and refresh token. We use that in mail server to send scheduled mails via smtp with OAuth authentication.

The generated access token is 6000 chars and when we encrypt it and save in a SQL Server database in a varchar column, encrypted char length exceeds 8000 and so we're unable to save the access token and use them.

Is there a way to control access token length? What could be the maximum length? How could we encrypt and save such long token in database?

Upvotes: 1

Views: 155

Answers (1)

Lajos Arpad
Lajos Arpad

Reputation: 77002

If you cannot reduce the length of the access token, then you could store the encrypted access token in a file on the server, generate a unique filename, a format of <user id>_<some hash> springs to mind and store that filename in the database instead. So you load the location of the encrypted access token instead of the value itself and you can always load it from file. Then you will not have to face this restriction.

Upvotes: -1

Related Questions