mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-12-20 17:30:46 +00:00
Changes for getting conversation token
This commit is contained in:
@@ -9,7 +9,7 @@ import {
|
||||
allowedJunoOrigins,
|
||||
allowedMongoBackendEndpoints,
|
||||
allowedMsalRedirectEndpoints,
|
||||
validateEndpoint,
|
||||
validateEndpoint
|
||||
} from "Utils/EndpointValidation";
|
||||
|
||||
export enum Platform {
|
||||
@@ -190,3 +190,4 @@ export async function initializeConfiguration(): Promise<ConfigContext> {
|
||||
}
|
||||
|
||||
export { configContext };
|
||||
|
||||
|
||||
@@ -30,13 +30,11 @@ export class SupportPaneComponent extends React.Component<SupportPaneComponentPr
|
||||
{
|
||||
...directLine,
|
||||
postActivity: (activity: any) => {
|
||||
// Add whatever needs to be added.
|
||||
activity.channelData.token = this.props.userToken;
|
||||
activity.channelData.subId = this.props.subId;
|
||||
activity.channelData.rg = this.props.rg;
|
||||
activity.channelData.accName = this.props.accName;
|
||||
|
||||
//activity.channelData.MyKey = "hello";
|
||||
return directLine.postActivity(activity)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { Link } from "@fluentui/react/lib/Link";
|
||||
import { isPublicInternetAccessAllowed } from "Common/DatabaseAccountUtility";
|
||||
import { configContext } from "ConfigContext";
|
||||
import { IGalleryItem } from "Juno/JunoClient";
|
||||
import * as ko from "knockout";
|
||||
import React from "react";
|
||||
@@ -34,6 +35,7 @@ import { userContext } from "../UserContext";
|
||||
import { getCollectionName, getUploadName } from "../Utils/APITypeUtils";
|
||||
import { update } from "../Utils/arm/generatedClients/cosmos/databaseAccounts";
|
||||
import { listByDatabaseAccount } from "../Utils/arm/generatedClients/cosmosNotebooks/notebookWorkspaces";
|
||||
import { getAuthorizationHeader } from "../Utils/AuthorizationUtils";
|
||||
import { stringToBlob } from "../Utils/BlobUtils";
|
||||
import { isCapabilityEnabled } from "../Utils/CapabilityUtils";
|
||||
import { fromContentUri, toRawContentUri } from "../Utils/GitHubUtils";
|
||||
@@ -479,26 +481,24 @@ export default class Explorer {
|
||||
name = tokenPayload.name;
|
||||
}
|
||||
} catch (error) {
|
||||
// ignore
|
||||
console.error("Exception while decrypting token");
|
||||
console.error(error);
|
||||
} finally {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
private async generateConversationToken() {
|
||||
const response = await fetch("https://directline.botframework.com/v3/directline/tokens/generate", {
|
||||
method: "POST",
|
||||
var url = `${configContext.JUNO_ENDPOINT}/api/chatbot/bot${userContext.databaseAccount.id}/conversationToken`;
|
||||
const authorizationHeader = getAuthorizationHeader();
|
||||
|
||||
const response = await fetch(url, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
[Constants.HttpHeaders.authorization]: "Bearer BSjLmJJHZRA.PxahjJGCNOKl7q9tiodWyVcqJOIzG894vAAqCme639o",
|
||||
[Constants.HttpHeaders.authorization]: authorizationHeader.token,
|
||||
Accept: "application/json",
|
||||
[Constants.HttpHeaders.contentType]: "application/json"
|
||||
},
|
||||
body: JSON.stringify({
|
||||
"user": {
|
||||
"id": `dl_${_.uniqueId()}`,
|
||||
"name": this.getUserName()
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
|
||||
Reference in New Issue
Block a user