-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
zuies
committed
Sep 26, 2023
1 parent
107929d
commit 56b8f33
Showing
4 changed files
with
38 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { StateCreator } from 'zustand'; | ||
import { axiosInstance } from '../../axiosInstance'; | ||
import ITwitter from '../types/ITwitter'; | ||
import { conf } from '../../configs'; | ||
|
||
const BASE_URL = conf.API_BASE_URL; | ||
|
||
const createTwitterSlice: StateCreator<ITwitter> = (set, get) => ({ | ||
authorizeTwitter: async (token: string) => { | ||
try { | ||
// Send token to intermediary endpoint | ||
await axiosInstance({ | ||
method: 'GET', // adjust as necessary | ||
url: `${BASE_URL}/auth/twitter/login`, | ||
headers: { | ||
Authorization: `Bearer ${token}`, | ||
}, | ||
}); | ||
|
||
// The above request should set some session or cookie authentication | ||
// and then redirect to the Twitter authorization URL. | ||
// Since it's a 302 redirect, you might not need to handle the response directly. | ||
} catch (error) { | ||
console.error('Error in intermediary auth step:', error); | ||
} | ||
}, | ||
}); | ||
|
||
export default createTwitterSlice; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default interface ITwitter { | ||
authorizeTwitter: (token: string) => void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters