-
Notifications
You must be signed in to change notification settings - Fork 395
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
Using the built-in OAuth, how can I access the rest of the fetched Installation from a listener? #685
Comments
I like this idea! So developers could access the entire |
Ah, just posted about something similar here: https://stackoverflow.com/questions/67453098/slackbolt-app-how-can-i-get-scopes-associated-with-the-current-request. Is this the same issue / will this resolve it? The main use case I care about now is if I want to add permissions over the course of many months to my app (but I don't want to force companies/users to install when I do the update, I can manage that separately), I want a way to basically know which teamIds have which scopes. Also if there's a workaround in the meantime or a suggested way of doing this, I'd love to hear it! I haven't found anything yet on the public internets :). maybe.... cc: @seratch will know? |
Hi @willyxiao, thanks for sharing your use case. Yes, if we resolve this issue, the update may be a solution for you. However, we haven't decided how/when we enhance the installation data access yet. A workaround I can suggest as of today would be defining our own For the |
Thank you SO much! Super helpful. @seratch one question - the current default authorize function looks like it's making a call to slack (via client.auth.test on line 890 in App.ts).
|
This is only for the case where you pass a token in Lines 359 to 367 in 9867e38
If your app enables OAuth and its installation store functions, Bolt uses the HTTPReceiver's default authorize function for OAuth: Line 375 in 9867e38
authorize function calls fetchInstallation internally.
Although it's not active recently, this is an issue for bolt-js's enhancement discussion. If you have followup questions or related ones, would you mind creating a new issue for your question or asking them in the Slack Platform Community workspace? In the community workspace, #lang-javascript #tools-bolt would be good places to have this type of Q&A. I would appreciate it if you could understand this! |
What is supposed to be returned exactly from the fetchInstallation call if using a publically installed app with Oauth? I am returning the authorized bot user token stored in my database as a string for the user invoking the app, but I get the error below: [WARN] bolt-app Authorization of incoming event did not succeed. No listeners will be called. |
@anthonygualandri To know the full list of available properties, you can check the |
Thanks @seratch and I'm so sorry, but I'm confused. The spot in the docs you sent me to says "If you’re using the built-in OAuth support authorization is handled by default, so you do not need to pass in an authorize option." Can it be something else here instead that you can point me to? |
@anthonygualandri Oh, I'm sorry. Somehow, I assumed that you've asked about authorize function. Please check this interface to learn the expected data structure as a returned value form |
Thanks @seratch, this is exactly what I needed and helped me get the right return values into the right data structure to get the app installing / loading properly. Will look to the code in the package in the future for anything that isn't detailed out in the Bolt concepts guide. |
is there an estimated release date for 4.x? |
Hey there, I got here because I'd like to access the team name from the installation object without getting it again from the DB. The "problem" as you said is that the Have you came up with a better solution that doesn't involve an useless database query? |
Wondering if this one needs to be set to the next major version milestone - @seratch thoughts? Could this be a minor update? Could we simply expose an additional parameter with the entire object, as discussed, to the relevant functions? E.g. have the |
@filmaj Simlpy allowing |
Description
The built in OAuth is super convenient and great! It fetches the appropriate
Installation
from myInstallationStore
and uses the tokens in that installation to authorize the incoming events. It also puts the relevant User ID and Bot User ID incontext
so I can access it from middleware and listeners.But the
Installation
has so much more in it than just those properties. For example, the installed scopes are stored, an incoming webhook may be stored, etc. If I wanted to access these, I'd currently have to performinstallationStore.fetchInstallation()
again inside my listener. The framework did that already though, so that's a waste.This could be solved in probably a few different ways, but I think one of the simplest would just be to add a new (optional) property called
installation
onAuthorizeResult
. The implementation ofauthorize()
that the built-in OAuth library uses would set that property to the wholeInstallation
it got fromfetchInstallation()
. Any customauthorize()
implementations could also set this value. Thatinstallation
property would then be added to thecontext
, just likebotToken
,userToken
, etc. Then listeners and middleware could use any installation data.Requirements (place an
x
in each of the[ ]
)The text was updated successfully, but these errors were encountered: