@@ -13,40 +13,21 @@ export class SlackProvider extends SocialAbstract implements SocialProvider {
1313 identifier = 'slack' ;
1414 name = 'Slack' ;
1515 isBetweenSteps = false ;
16- scopes = [ 'identify' , 'guilds' ] ;
16+ scopes = [
17+ 'channels:read' ,
18+ 'chat:write' ,
19+ 'users:read' ,
20+ 'groups:read' ,
21+ 'channels:join' ,
22+ 'chat:write.customize' ,
23+ ] ;
1724 async refreshToken ( refreshToken : string ) : Promise < AuthTokenDetails > {
18- const { access_token, expires_in, refresh_token } = await (
19- await this . fetch ( 'https://discord.com/api/oauth2/token' , {
20- method : 'POST' ,
21- body : new URLSearchParams ( {
22- refresh_token : refreshToken ,
23- grant_type : 'refresh_token' ,
24- } ) ,
25- headers : {
26- 'Content-Type' : 'application/x-www-form-urlencoded' ,
27- Authorization : `Basic ${ Buffer . from (
28- process . env . DISCORD_CLIENT_ID +
29- ':' +
30- process . env . DISCORD_CLIENT_SECRET
31- ) . toString ( 'base64' ) } `,
32- } ,
33- } )
34- ) . json ( ) ;
35-
36- const { application } = await (
37- await fetch ( 'https://discord.com/api/oauth2/@me' , {
38- headers : {
39- Authorization : `Bearer ${ access_token } ` ,
40- } ,
41- } )
42- ) . json ( ) ;
43-
4425 return {
45- refreshToken : refresh_token ,
46- expiresIn : expires_in ,
47- accessToken : access_token ,
26+ refreshToken : '' ,
27+ expiresIn : 1000000 ,
28+ accessToken : '' ,
4829 id : '' ,
49- name : application . name ,
30+ name : '' ,
5031 picture : '' ,
5132 username : '' ,
5233 } ;
@@ -76,7 +57,7 @@ export class SlackProvider extends SocialAbstract implements SocialProvider {
7657 codeVerifier : string ;
7758 refresh ?: string ;
7859 } ) {
79- const { access_token, team, bot_user_id, authed_user , ... all } = await (
60+ const { access_token, team, bot_user_id, scope } = await (
8061 await this . fetch ( `https://slack.com/api/oauth.v2.access` , {
8162 method : 'POST' ,
8263 headers : {
@@ -97,6 +78,8 @@ export class SlackProvider extends SocialAbstract implements SocialProvider {
9778 } )
9879 ) . json ( ) ;
9980
81+ this . checkScopes ( this . scopes , scope . split ( ',' ) ) ;
82+
10083 const { user } = await (
10184 await fetch ( `https://slack.com/api/users.info?user=${ bot_user_id } ` , {
10285 method : 'GET' ,
@@ -112,7 +95,7 @@ export class SlackProvider extends SocialAbstract implements SocialProvider {
11295 accessToken : access_token ,
11396 refreshToken : 'null' ,
11497 expiresIn : dayjs ( ) . add ( 100 , 'years' ) . unix ( ) - dayjs ( ) . unix ( ) ,
115- picture : user . profile . image_48 ,
98+ picture : user . profile . image_original ,
11699 username : user . name ,
117100 } ;
118101 }
0 commit comments