Fix some refactiring error. And Add a way to insert admin credentials
This commit is contained in:
@ -27,21 +27,21 @@ class PeerTubeRequester {
|
||||
this.password = config.password;
|
||||
}
|
||||
|
||||
private async requestAuthToken(): Promise<any> {
|
||||
async requestAuthToken(): Promise<any> {
|
||||
let response = await fetch(
|
||||
new URL(`/api/v1/oauth-clients/local`, this.domainName)
|
||||
);
|
||||
if (!response.ok) {
|
||||
throw new Error(response.statusText); // CRASH
|
||||
throw new Error("Cannot get client credentials : " + response.statusText); // CRASH
|
||||
}
|
||||
const { client_id: clientId, client_secret: clientSecret } =
|
||||
await response.json();
|
||||
|
||||
const clientInfo: { [key: string]: string } = {
|
||||
clientId,
|
||||
clientSecret,
|
||||
grantType: "password",
|
||||
responseType: "code",
|
||||
client_id: clientId,
|
||||
client_secret: clientSecret,
|
||||
grant_type: "password",
|
||||
response_type: "code",
|
||||
username: this.username,
|
||||
password: this.password,
|
||||
};
|
||||
@ -54,7 +54,7 @@ class PeerTubeRequester {
|
||||
body: myParams,
|
||||
});
|
||||
if (!response.ok) {
|
||||
throw new Error(response.statusText); // CRASH
|
||||
throw new Error("Cannot get access Token : " + response.statusText); // CRASH
|
||||
}
|
||||
const { access_token: accessToken } = await response.json();
|
||||
return accessToken;
|
||||
|
Reference in New Issue
Block a user