Sean
Sean
KKinde
Created by Sean on 1/25/2025 in #💻┃support
Android getToken in non-activity classes.
Hi, In my use case, I'm trying to request to an API hosted on cloudflare worker in an Android background service. My plan is to use the getToken method to get the JWT, and the worker will verify the JWT, once its verified the worker will perform some task and return the result. However, I found that an AppCompatActivity is required to initialize the SDK, which is not possible to obtain in a background task. Thus I can't use the SDK nor get the JWT in non-activity classes. Is there an official way to mitigate this issue? I read the source code of the SDK. It seems like only the login and logout tasks requires an actual Activity. The rest of them including getToken() should work with a Context instance, which is quite easy to obtain in background tasks. If you guys are OK, I can submit a pull request to improve this 🙂 Thanks in advance!
2 replies