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