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 {
|
export default class Auth extends Vue {
|
||||||
public instance: Instance = ""
|
public instance: Instance = ""
|
||||||
public inputCode: boolean = false
|
public inputCode: boolean = false
|
||||||
|
public code: string
|
||||||
public get hasDomain() {
|
public get hasDomain() {
|
||||||
return this.instance != ""
|
return this.instance != ""
|
||||||
}
|
}
|
||||||
|
@ -37,7 +38,7 @@ export default class Auth extends Vue {
|
||||||
public authCode() {
|
public authCode() {
|
||||||
let code = this.code
|
let code = this.code
|
||||||
this.inputCode = true
|
this.inputCode = true
|
||||||
ipcRenderer.send(`new-account-setup`, target)
|
ipcRenderer.send(`new-account-auth`, code, this.instance)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -3,10 +3,10 @@ import Mastodon from "megalodon"
|
||||||
|
|
||||||
export default class Auth {
|
export default class Auth {
|
||||||
public static ready() {
|
public static ready() {
|
||||||
ipcMain.on("new-account-setup", async (event: Event, instance: string) => {
|
|
||||||
const SCOPES: string = "read write follow"
|
|
||||||
let clientId: string
|
let clientId: string
|
||||||
let clientSecret: string
|
let clientSecret: string
|
||||||
|
ipcMain.on("new-account-setup", async (event: Event, instance: string) => {
|
||||||
|
const SCOPES: string = "read write follow"
|
||||||
let url: string | null
|
let url: string | null
|
||||||
Mastodon.registerApp(
|
Mastodon.registerApp(
|
||||||
"TheDesk",
|
"TheDesk",
|
||||||
|
@ -31,8 +31,14 @@ export default class Auth {
|
||||||
} else {
|
} else {
|
||||||
console.log(appData)
|
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