Python coding in notebook with a (long) token
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2025 03:20 PM - edited 04-16-2025 03:22 PM
I have written a python program (called by a trigger) that uses a token issued by a third party app (it's circa 400 bytes long including '.' and '-'). When I copy/paste this token into a Databricks notebook - curious formatting takes place and a couple of line breaks appear to be inserted. I believe this formatting corrupts my token (and my program fails). In contrast, when I recreate the same program into a juypter notebook, along with a new pasted copy of the token - it appears as a single uninterrupted record (and my program works).
My suspicion is the Notebook GUI is trying to be clever (but in the case of my token - it's corrupted). What can I do to get the same behaviour as with Juypter ? I've seen mention of a Black python code formatter but I don't believe I'm using this - simply default Notebook. Alternatively - must I do something else to encapsulate the token so that its integrity is preserved ?
Thanks Paul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2025 11:05 PM
Hey Paul, You can use databricks secrets for preserving the integrity of the token.
Here's the databricks doc for refernece : https://docs.databricks.com/aws/en/security/secrets
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2025 12:32 AM
Yes, that's a good suggestion, thanks. However, I've spotted that even though notebook inserts what appears to be a new line after any '.' characters, my token string still only occupies one record (in the notebook). This leads me to think that it retains its fidelity (despite the quirky formatting). I'll include a pic of a long-dead token to show you what I mean.