Add: get access token
This commit is contained in:
parent
4887dfbd5b
commit
fd719a0235
|
@ -26,6 +26,7 @@ type Instance = string
|
|||
export default class Auth extends Vue {
|
||||
public instance: Instance = ""
|
||||
public inputCode: boolean = false
|
||||
public code: string
|
||||
public get hasDomain() {
|
||||
return this.instance != ""
|
||||
}
|
||||
|
@ -37,7 +38,7 @@ export default class Auth extends Vue {
|
|||
public authCode() {
|
||||
let code = this.code
|
||||
this.inputCode = true
|
||||
ipcRenderer.send(`new-account-setup`, target)
|
||||
ipcRenderer.send(`new-account-auth`, code, this.instance)
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -3,10 +3,10 @@ import Mastodon from "megalodon"
|
|||
|
||||
export default class Auth {
|
||||
public static ready() {
|
||||
ipcMain.on("new-account-setup", async (event: Event, instance: string) => {
|
||||
const SCOPES: string = "read write follow"
|
||||
let clientId: string
|
||||
let clientSecret: string
|
||||
ipcMain.on("new-account-setup", async (event: Event, instance: string) => {
|
||||
const SCOPES: string = "read write follow"
|
||||
let url: string | null
|
||||
Mastodon.registerApp(
|
||||
"TheDesk",
|
||||
|
@ -31,8 +31,14 @@ export default class Auth {
|
|||
} else {
|
||||
console.log(appData)
|
||||
}
|
||||
|
||||
})
|
||||
})
|
||||
ipcMain.on("new-account-auth", async (event: Event, code: string, instance: string) => {
|
||||
Mastodon.fetchAccessToken(clientId, clientSecret, code, "https://"+instance)
|
||||
.then((tokenData: Partial<{ accessToken: string }>) => {
|
||||
console.log(tokenData.accessToken)
|
||||
})
|
||||
.catch((err: Error) => console.error(err))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user