Slack Oauth/Authorize API Call

血红的双手。 提交于 2019-12-13 01:54:23

问题


I'm new to OAuth (and the Slack API) and have a question regarding Step 1 of Slack's OAuth Flow.

It says "Your web or mobile app should redirect users to the following url: https://slack.com/oauth/authorize". At first I thought I should do an XHR request but then came to understand that that is not what I want.

After more research, I found that the initial oauth/authorize request should be sent as a direct request in the browser. My problem is I can't begin to visualize how this should be done. I've been referencing parts of this tutorial (scroll down to 'Web Server Apps' section) but it doesn't help me to be able to wrap my head around the oauth/authorize petition.

So basically, I'm looking for someone to better explain to me how that initial petition is supposed to be made. Any and all help is greatly appreciated!

Thanks in advance


回答1:


You should check out the Slack button docs.

There you will find an example for your slackapp, something like:

<a href="https://slack.com/oauth/authorize?scope=incoming-webhook&client_id=CLIENT_ID">
   <img alt="Add to Slack" height="40" width="139" 
   src="https://platform.slack-edge.com/img/add_to_slack.png" />
</a>

This button asks for authorization for a slackapp that includes incoming webhooks, you can add more features needed inside scope separating them by commas. scope=incoming-webhook,commands,bot,channels:read

As of your tutorial link, when it says you should link them to https://oauth2server.com/auth?response_type=code&client_id=CLIENT_ID&redirect_uri=REDIRECT_URI&scope=photos

It is refering to wrap that into a button for the user:

<a href="https://oauth2server.com/auth?response_type=code&client_id=CLIENT_ID&redirect_uri=REDIRECT_URI&scope=photos">
   Auth Button
</a>

Hope this helps clarify the usage of /oauth/authorize



来源:https://stackoverflow.com/questions/37193395/slack-oauth-authorize-api-call

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!