我已经在我的Cortana通道(Microsoft)中启用了连接的服务,并获得了BOT框架的令牌。现在,我希望使用已注册的客户端id和密钥从令牌中检索用户详细信息
BOT框架中的示例代码:
var authInfo = ((Activity)context.Activity).Entities.FirstOrDefault(e => e.Type.Equals("AuthorizationToken"));
var token = authInfo.Properties["token"].ToString();有什么想法吗?
发布于 2018-03-16 07:49:35
查看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://stackoverflow.com/questions/49287289
复制相似问题