feat: implement Spotify connection
This commit is contained in:
12
packages/backend/src/apps/spotify/common/add-auth-header.ts
Normal file
12
packages/backend/src/apps/spotify/common/add-auth-header.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { TBeforeRequest } from '@automatisch/types';
|
||||
|
||||
const addAuthHeader: TBeforeRequest = ($, requestConfig) => {
|
||||
if ($.auth.data?.accessToken) {
|
||||
const authorizationHeader = `Bearer ${$.auth.data.accessToken}`;
|
||||
requestConfig.headers.Authorization = authorizationHeader;
|
||||
}
|
||||
|
||||
return requestConfig;
|
||||
};
|
||||
|
||||
export default addAuthHeader;
|
10
packages/backend/src/apps/spotify/common/get-current-user.ts
Normal file
10
packages/backend/src/apps/spotify/common/get-current-user.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { IGlobalVariable, IJSONObject } from '@automatisch/types';
|
||||
|
||||
const getCurrentUser = async ($: IGlobalVariable): Promise<IJSONObject> => {
|
||||
const response = await $.http.get('/v1/me');
|
||||
const currentUser = response.data;
|
||||
|
||||
return currentUser;
|
||||
};
|
||||
|
||||
export default getCurrentUser;
|
13
packages/backend/src/apps/spotify/common/scopes.ts
Normal file
13
packages/backend/src/apps/spotify/common/scopes.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
const scopes = [
|
||||
'user-follow-read',
|
||||
'playlist-read-private',
|
||||
'playlist-read-collaborative',
|
||||
'user-library-read',
|
||||
'playlist-modify-public',
|
||||
'playlist-modify-private',
|
||||
'user-library-modify',
|
||||
'user-follow-modify',
|
||||
'user-follow-read',
|
||||
];
|
||||
|
||||
export default scopes;
|
Reference in New Issue
Block a user