1

我已经在我的 Cortana 频道 (Microsoft) 中启用了连接的服务,并获得了 BOT 框架的令牌。现在,我想使用注册的客户端 ID 和密码从令牌中检索用户详细信息

BOT框架中的示例代码:

var authInfo = ((Activity)context.Activity).Entities.FirstOrDefault(e => e.Type.Equals("AuthorizationToken"));
            var token = authInfo.Properties["token"].ToString();

有什么想法吗?

4

1 回答 1

1

检查BotAuth。您可以选择提供者来检索令牌:

const botauth = require("botauth");
const DropboxOAuth2Strategy = require("passport-dropbox-oauth2").Strategy;

...

 // Initialize with the strategies we want to use
var auth = new botauth.BotAuthenticator(server, bot, {
    secret : "something secret",
    baseUrl : "https://" + WEBSITE_HOSTNAME }
);

// Configure the Dropbox authentication provider using the passport-dropbox strategy
auth.provider("dropbox",
    function(options) {
        return new DropboxOAuth2Strategy(
            {
                    clientID : DROPBOX_APP_ID,
                    clientSecret : DROPBOX_APP_SECRET,
                    callbackURL : options.callbackURL
            },
            function(accessToken, refreshToken, profile, done) {
                profile.accessToken = accessToken;
                profile.refreshToken = refreshToken;
                done(null, profile);
            }
        );
    }
);

如果您只想检索用户名和 ID,可以从userData对象中获取:

UserInfo : { "Name": { "GivenName": "XYZ", "FamilyName": "ABC" }, "Id": "something@outlook.com" }

https://github.com/Microsoft/BotBuilder/issues/3242

于 2018-03-15T23:49:34.890 回答