Merge pull request #263 from h3poteto/fix/optional
Allow optional parameter in fetchAccessToken
This commit is contained in:
commit
d797f8202f
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue