Category Hierarchy

我正在尝试获取令牌,以便在我的应用程序中使用IBM Watson Speech- to -Text。下面是我的代码:

const { IamAuthenticator } = require('ibm-cloud-sdk-core');

const authenticator = new IamAuthenticator({
    apikey: 'myApiKey',
  });

  authenticator.getToken(function (err, token) {
    if (!token) {
      console.log('error: ', err);
    } else {
      // use token
    }
  });

错误消息为authenticator.getToken is not a function

documentation说:

string IBM.Cloud.SDK.Core.Authentication.Iam.IamAuthenticator.GetToken  (       )   

我已经尝试过getTokenGetToken了。相同的错误信息。代码并不复杂,我哪里做错了?

转载请注明出处:http://www.qdnewhouse.com/article/20230526/1944977.html