Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate API TOKEN #1427

Open
lgvalle opened this issue May 19, 2023 · 3 comments
Open

Validate API TOKEN #1427

lgvalle opened this issue May 19, 2023 · 3 comments
Labels
enhancement New feature or request

Comments

@lgvalle
Copy link

lgvalle commented May 19, 2023

Are you requesting automatic instrumentation for a framework or library? Please describe.
using library dd-sdk-android:1.17.2

Is your feature request related to a problem? Please describe.
Yes, if the datadog Android SDK is initialised using a wrong Token there's no way to know other than events not appearing on Datadog Dashboard, which is a very manual and prone to errors process.

Describe the solution you'd like
A function in the SDK to validate that the token passed to initialise it is correct. Something similar to the functionality of the existing API endpoint to validate API KEYs

Describe alternatives you've considered
I've tried two options with no luck

  1. Use the validate-api-key endpoint linked above passing an API TOKEN
  2. Use the Datadog JVM dependency for unit tests in our Android app, since it does have a validate functionality

In both cases, I received the same 403 error and I believe it's because API TOKENS cannot be used against the validate-api-key endpoint

Thanks!

@lgvalle lgvalle added the enhancement New feature or request label May 19, 2023
@0xnm
Copy link
Member

0xnm commented May 19, 2023

Hello @lgvalle!

When token is invalid you should have an error in the logcat, given that you set logs verbosity using Datadog.setVerbosity call (by default no logs will be printed).

@lgvalle
Copy link
Author

lgvalle commented May 19, 2023

Thanks @0xnm , that's totally true: you can see that error message in the logs.
I want to achieve an automatic check that Datadog has been initialised correctly. Inspecting the logs requires a manual process. I'd like to be able to stop a production build on the CI if Datadog cannot be initialised.

The immediate solutions I can think of are: if the Datadog.initialize function would check the token validity as part of the initialisation process it'll be fantastic. Alternatively, a listener to hook into the upload function to receive upload results not only on the logs would be good too.

@0xnm
Copy link
Member

0xnm commented May 19, 2023

Thank you for the suggestion, we will check what we can do indeed. Generally speaking, validating client setup is more complicated topic, because missing data in Datadog dashboards may be related not only to the wrong token/site usage, but also mistakes in the instrumentation setup itself.

Although we are trying to notify the user if there is something wrong in their setup as much as we can, there is definitely some room for the improvement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants