Skip to main content
Tutorial

How to generate a Basic Auth header

  • September 22, 2022
  • 2 replies
  • 454 views

Forum|alt.badge.img+3

Basic Auth headers are frequently used as part of communication between applications, e.g. as part of API calls.

Common use cases in the Ataccama context include (and not limited to):

  • Graphql call to ONE application
  • API call to an online service set up on a DQC / runtime / orchestration server

Option 1: Do it in a ONE Desktop plan

  • Create a new plan

  • Create a step that evaluates expressions, e.g. Alter Format

  • Go into the expression window and put this expression in. The username and password are separated with a colon:

    coding.toBase64('username:password')

  • Click Evaluate
  • Copy the result string
  • Your header is going to be Basic dXNlcm5hbWU6cGFzc3dvcmQ=

Option 2: Use an online base64 encode website

If you are building something to integrate with Ataccama but you don’t actually have Ataccama ONE Desktop installed….

  • Go to a website that offers this conversion (e.g. link. Warning: this site is not affiliated with Ataccama)

  • Put in your username and password in this format: username:password, separated by a colon

  • Convert. (Result of the conversion = dXNlcm5hbWU6cGFzc3dvcmQ=)

  • Take that string and make your header like so:

    Basic dXNlcm5hbWU6cGFzc3dvcmQ=

Option 3: Linux/Unix/MacOS shell

  • In the shell, use command:

    echo -n user:password | base64

Option 4: Windows 7 or later, Power Shell

$Text = ‘user:password’
$Bytes = [System.Text.Encoding]::UTF8.GetBytes($Text)
$EncodedText = [Convert]::ToBase64String($Bytes)
$EncodedText

Once done, you can make the Http header for our Graphql calls in our Graphql playground, in this format:

{”Authorization”: “Basic dXNlcm5hbWU6cGFzc3dvcmQ=”}

Or in ONE Desktop Json Call step:

 

2 replies

Forum|alt.badge.img+3
  • Author
  • Data Pioneer L2
  • 16 replies
  • January 25, 2023

I found a way to do encode base64 in Notepad++!

 


Maxim Kim
Ataccamer
Forum|alt.badge.img+3
  • Ataccamer
  • 33 replies
  • January 31, 2023

 

I found a way to do encode base64 in Notepad++!

 

You can also use python in command line (both windows and *nix like OS):

~ $ echo username:password | python -m base64
dXNlcm5hbWU6cGFzc3dvcmQK

It would be essentially the same as linux base64 command you mentioned:

~ $ echo username:password | base64
dXNlcm5hbWU6cGFzc3dvcmQK