Allow optional parameter in fetchAccessToken

This commit is contained in:
AkiraFukushima 2020-03-17 20:08:26 +09:00
parent 1f86caaaf4
commit d8f0c989c1
3 changed files with 8 additions and 5 deletions

View file

@ -130,11 +130,14 @@ export default class Mastodon implements MegalodonInterface {
// apps/oauth
// ======================================
public async fetchAccessToken(
client_id: string,
client_id: string | null,
client_secret: string,
code: string,
redirect_uri = NO_REDIRECT
redirect_uri: string | null = NO_REDIRECT
): Promise<OAuth.TokenData> {
if (!client_id) {
throw new Error('client_id is required')
}
return this.client
.post<OAuth.TokenDataFromServer>('/oauth/token', {
client_id,

View file

@ -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, client_secret: string, code: string, redirect_uri: string): Promise<OAuth.TokenData>
fetchAccessToken(client_id: string | null, client_secret: string, code: string, redirect_uri?: string | null): Promise<OAuth.TokenData>
/**
* POST /oauth/token

View file

@ -150,10 +150,10 @@ export default class Misskey implements MegalodonInterface {
* @param _redirect_uri This parameter is not used in this method.
*/
public async fetchAccessToken(
_client_id: string,
_client_id: string | null,
client_secret: string,
session_token: string,
_redirect_uri: string
_redirect_uri?: string | null
): Promise<OAuth.TokenData> {
return MisskeyAPI.Client.post<MisskeyAPI.Entity.UserKey>('/api/auth/session/userkey', {
appSecret: client_secret,