Fix scopes for mastodon and fix examples
This commit is contained in:
parent
887b4ec679
commit
152031f91e
|
@ -7,7 +7,7 @@ const rl: readline.ReadLine = readline.createInterface({
|
|||
})
|
||||
|
||||
const SCOPES: Array<string> = ['read', 'write', 'follow']
|
||||
const BASE_URL: string = 'https://mastodon.social'
|
||||
const BASE_URL: string = 'https://mstdn.maud.io'
|
||||
|
||||
let clientId: string
|
||||
let clientSecret: string
|
||||
|
@ -32,7 +32,7 @@ client
|
|||
})
|
||||
})
|
||||
.then((code: string) => {
|
||||
return client.fetchAccessToken(clientId, clientSecret, code, BASE_URL)
|
||||
return client.fetchAccessToken(clientId, clientSecret, code)
|
||||
})
|
||||
.then((tokenData: OAuth.TokenData) => {
|
||||
console.log('\naccess_token:')
|
||||
|
|
|
@ -34,7 +34,7 @@ client
|
|||
if (!session_token) {
|
||||
throw new Error('Could not get session token')
|
||||
}
|
||||
return client.fetchAccessToken(clientId, clientSecret, session_token, BASE_URL)
|
||||
return client.fetchAccessToken(clientId, clientSecret, session_token)
|
||||
})
|
||||
.then((tokenData: OAuth.TokenData) => {
|
||||
console.log('\naccess_token:')
|
||||
|
|
|
@ -32,7 +32,7 @@ client
|
|||
})
|
||||
})
|
||||
.then((code: string) => {
|
||||
return client.fetchAccessToken(clientId, clientSecret, code, BASE_URL)
|
||||
return client.fetchAccessToken(clientId, clientSecret, code)
|
||||
})
|
||||
.then((tokenData: OAuth.TokenData) => {
|
||||
console.log('\naccess_token:')
|
||||
|
|
|
@ -113,7 +113,7 @@ export default class Mastodon implements MegalodonInterface {
|
|||
redirect_uri: options.redirect_uri,
|
||||
response_type: 'code',
|
||||
client_id: clientId,
|
||||
scope: options.scope!.join(',')
|
||||
scope: options.scope!.join(' ')
|
||||
})
|
||||
resolve(url)
|
||||
})
|
||||
|
@ -133,7 +133,7 @@ export default class Mastodon implements MegalodonInterface {
|
|||
client_id: string | null,
|
||||
client_secret: string,
|
||||
code: string,
|
||||
redirect_uri: string | null = NO_REDIRECT
|
||||
redirect_uri: string = NO_REDIRECT
|
||||
): Promise<OAuth.TokenData> {
|
||||
if (!client_id) {
|
||||
throw new Error('client_id is required')
|
||||
|
|
|
@ -82,7 +82,7 @@ export interface MegalodonInterface {
|
|||
* @param code will be generated by the link of #generateAuthUrl or #registerApp
|
||||
* @param redirect_uri must be the same uri as the time when you register your OAuth application
|
||||
*/
|
||||
fetchAccessToken(client_id: string | null, client_secret: string, code: string, redirect_uri?: string | null): Promise<OAuth.TokenData>
|
||||
fetchAccessToken(client_id: string | null, client_secret: string, code: string, redirect_uri?: string): Promise<OAuth.TokenData>
|
||||
|
||||
/**
|
||||
* POST /oauth/token
|
||||
|
|
|
@ -153,7 +153,7 @@ export default class Misskey implements MegalodonInterface {
|
|||
_client_id: string | null,
|
||||
client_secret: string,
|
||||
session_token: string,
|
||||
_redirect_uri?: string | null
|
||||
_redirect_uri?: string
|
||||
): Promise<OAuth.TokenData> {
|
||||
return MisskeyAPI.Client.post<MisskeyAPI.Entity.UserKey>('/api/auth/session/userkey', {
|
||||
appSecret: client_secret,
|
||||
|
|
Loading…
Reference in a new issue