How to use a bearer token for authentication using Python SDK
I am trying to use a bearer token for authentication using Python SDK.
On the documentation I found several examples using the LMv1 access_id and access_key values, like this:
but couldn’t find any example on using bearer token for authentication.
After some search I found something about defining “api_token” and “api_token_prefix” but couldn’t get it to work.
Anybody have any example I could follow to use this?
21 comments
LM User
·2 years agoUpdating this thread with some good news! 🎉
v198 of the portal, you can now use bearer tokens for both Python and Go SDKs
https://www.logicmonitor.com/release-notes/v-198-release-notes
Here’s the updated documentation. I assume the SDK would need to be downloaded again?
Michael Raymond
·2 years agoUpdating this thread with some good news! 🎉
v198 of the portal, you can now use bearer tokens for both Python and Go SDKs
https://www.logicmonitor.com/release-notes/v-198-release-notes
LM User
·2 years agoAnd this makes it even easier to use with a regular id/key pair.
Michael Raymond
·2 years agoSeconding @Stuart Weenig’s questions and implication that bearer tokens with the SDK is less beneficial than with the API. The SDK already abstracts away the auth signature steps.
That all said, our API team has acknowledged that bearer token support in the SDK would be a good addition. I don’t have any further details on if/when this would be included in future roadmaps.
Michael Raymond
·2 years agoIs the python SDK repo available for PRs? Would LM even consider PRs?
Right, this is the part I’m talking about. I believe the answer to both is “no”.
LM User
·2 years agoI am trying to use a bearer token for authentication using Python SDK.
On the documentation I found several examples using the LMv1 access_id and access_key values, like this:
but couldn’t find any example on using bearer token for authentication.
After some search I found something about defining “api_token” and “api_token_prefix” but couldn’t get it to work.
Anybody have any example I could follow to use this?
Is there a particular reason you want to use a bearer token? When using the SDK, they’re just as easy except that there are three env variables instead of one.
LM User
·2 years agoIf he submits the PR, it would get baked into the official repo version of the sdk. At that point it wouldn’t be a workaround, it would be built in.
Is the python SDK repo available for PRs? Would LM even consider PRs?
Michael Raymond
·2 years ago@David Bond -- I’m not entirely sure what the pull request process is (of if it even exists) for the Python SDK… but if you want, please feel free to share the steps here. I’m sure others would appreciate an unofficial workaround to hold them over until this is officially added.
David Bond
·2 years ago@Joe Williams - sorry that you felt that offering our free library is "shilling", I'll stay out of the Python space in future.
Alternatively, I could provide a pull request for the python SDK. Adding bearer token support should be trivial to add to the SDK- it was only a couple of lines of code for us.
Michael Raymond
·2 years ago@Javier -- I have received confirmation from our dev team that, at least currently, bearer tokens are not supported with the SDK.
Please feel encouraged to submit product feedback within your portal so our Product team can prioritize this! You can submit feedback from within your portal in the 'Support' menu.
LM User
·2 years agoIf you feel it’s not meeting community standards, feel free to report the post. You can put your comments in the report and the moderators can make a decision.
I do agree it’s off topic though.
Kwame Armstrong
·2 years agoWhy is a wrong answer marked as the answer and why is someone shilling their .NET implementation of the SDK in a discussion on the python SDK?
He must have missed the sign about “No Shilling”
Javier Llorente
OP2 years agoAgree. This question is not solved.
Joe Williams
·2 years agoWhy is a wrong answer marked as the answer and why is someone shilling their .NET implementation of the SDK in a discussion on the python SDK?
David Bond
·2 years agoFor .NET developers…
We are looking to add support for the LogicMonitor.Api nuget package (see my signature) within the next couple of weeks.
Michael Raymond
·2 years ago@Javier -- I’ve submitted a request for bearer token usage to be included in our documentation. It does look to be possible; however, I am unsure of the proper usage. So far, my tests have failed.
I’ll update this thread with any additional findings!
Javier Llorente
OP2 years agoI was trying something like this:
but when trying to do any call, I always get a denied access (401) error message.
abhishek_bhambo
·2 years agoI believe it should work.
Michael Raymond
·2 years agoHi @Javier! This is a great question. I’m doing some internal investigation and testing to see if this is supported.
Of course, if anyone else has already had luck with this, please do chime in!
Javier Llorente
OP2 years agoI read that article but I’m afraid it doesn’t mention anything about using bearer tokens in the LogicMonitor SDK.
abhishek_bhambo
·2 years agoThis support article appears when searching for the keyword "Bearer" in the LM documentation: https://www.logicmonitor.com/support/bearer-token. Please inform us if this article provides assistance.