Skip to content

Commit

Permalink
Update token endpoints for samples (#5290)
Browse files Browse the repository at this point in the history
* Update token endpoint

* Update token endpoint
  • Loading branch information
compulim authored Sep 10, 2024
1 parent a58802f commit adf280e
Show file tree
Hide file tree
Showing 112 changed files with 627 additions and 424 deletions.
5 changes: 4 additions & 1 deletion __tests__/html/speechRecognition.simple.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ describe.each([
}

const { token } = await (
await fetch('https://webchat-mockbot3.azurewebsites.net/api/token/directline', { method: 'POST' })
await fetch(
'https://hawo-mockbot4-token-app.blueriver-ce85e8f0.westus.azurecontainerapps.io/api/token/directline',
{ method: 'POST' }
)
).json();

const params = new URLSearchParams({
Expand Down
2 changes: 1 addition & 1 deletion packages/embed/hostDevServer.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const DEFAULT_BOT_ID = 'webchat-mockbot';
const app = express();

app.get('/', async (_, res) => {
const tokenRes = await fetch('https://webchat-mockbot.azurewebsites.net/directline/token', { method: 'POST' });
const tokenRes = await fetch('https://hawo-mockbot4-token-app.blueriver-ce85e8f0.westus.azurecontainerapps.io/api/token/directline', { method: 'POST' });

if (!tokenRes.ok) {
return res.send(500);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default async function fetchDirectLineAppServiceExtensionToken() {
throw new Error('Failed to fetch Direct Line App Service Extension token.');
}

const { token } = await res.json();
const { domain, token } = await res.json();

return { domain: new URL('https://hawo-mockbot4-bot-app.azurewebsites.net/.bot/v3/directline').toString(), token };
return { domain, token };
}
4 changes: 2 additions & 2 deletions samples/00.migration/a.v3-to-v4/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ Next, the code to render Web Chat must be updated in the body. Note that MockBot
- resize: 'detect'
- }, document.getElementById("bot"));
+ (async function () {
+ const res = await fetch('https://webchat-mockbot.azurewebsites.net/directline/token', { method: 'POST' });
+ const res = await fetch('https://hawo-mockbot4-token-app.blueriver-ce85e8f0.westus.azurecontainerapps.io/api/token/directline', { method: 'POST' });
+ const { token } = await res.json();
+
+ window.WebChat.renderWebChat({
Expand Down Expand Up @@ -186,7 +186,7 @@ Here is the finished `index.html`:
<div id="webchat" role="main"></div>
<script>
(async function() {
const res = await fetch('https://webchat-mockbot.azurewebsites.net/directline/token', { method: 'POST' });
const res = await fetch('https://hawo-mockbot4-token-app.blueriver-ce85e8f0.westus.azurecontainerapps.io/api/token/directline', { method: 'POST' });
const { token } = await res.json();
window.WebChat.renderWebChat(
Expand Down
7 changes: 5 additions & 2 deletions samples/00.migration/a.v3-to-v4/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en-US">
<head>
<title>Web Chat: Full-featured bundle</title>
Expand Down Expand Up @@ -33,7 +33,10 @@
// Tokens are more secure. To learn about the differences between secrets and tokens
// and to understand the risks associated with using secrets, visit https://docs.microsoft.com/en-us/azure/bot-service/rest-api/bot-framework-rest-direct-line-3-0-authentication?view=azure-bot-service-4.0

const res = await fetch('https://webchat-mockbot.azurewebsites.net/directline/token', { method: 'POST' });
const res = await fetch(
'https://hawo-mockbot4-token-app.blueriver-ce85e8f0.westus.azurecontainerapps.io/api/token/directline',
{ method: 'POST' }
);
const { token } = await res.json();

window.WebChat.renderWebChat(
Expand Down
4 changes: 2 additions & 2 deletions samples/01.getting-started/a.full-bundle/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ We'll start by adding the CDN to the head of a blank `index.html` template.
+ <div id="webchat" role="main"></div>
+ <script>
+ (async function () {
+ const res = await fetch('https://webchat-mockbot.azurewebsites.net/directline/token', { method: 'POST' });
+ const res = await fetch('https://hawo-mockbot4-token-app.blueriver-ce85e8f0.westus.azurecontainerapps.io/api/token/directline', { method: 'POST' });
+ const { token } = await res.json();
+ window.WebChat.renderWebChat({
+ directLine: window.WebChat.createDirectLine({ token })
Expand Down Expand Up @@ -137,7 +137,7 @@ Here is the finished `index.html`:
<div id="webchat" role="main"></div>
<script>
(async function() {
const res = await fetch('https://webchat-mockbot.azurewebsites.net/directline/token', { method: 'POST' });
const res = await fetch('https://hawo-mockbot4-token-app.blueriver-ce85e8f0.westus.azurecontainerapps.io/api/token/directline', { method: 'POST' });
const { token } = await res.json();
window.WebChat.renderWebChat(
Expand Down
7 changes: 5 additions & 2 deletions samples/01.getting-started/a.full-bundle/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en-US">
<head>
<title>Web Chat: Full-featured bundle</title>
Expand Down Expand Up @@ -33,7 +33,10 @@
// Tokens are more secure. To learn about the differences between secrets and tokens
// and to understand the risks associated with using secrets, visit https://docs.microsoft.com/en-us/azure/bot-service/rest-api/bot-framework-rest-direct-line-3-0-authentication?view=azure-bot-service-4.0

const res = await fetch('https://webchat-mockbot.azurewebsites.net/directline/token', { method: 'POST' });
const res = await fetch(
'https://hawo-mockbot4-token-app.blueriver-ce85e8f0.westus.azurecontainerapps.io/api/token/directline',
{ method: 'POST' }
);
const { token } = await res.json();

window.WebChat.renderWebChat(
Expand Down
2 changes: 1 addition & 1 deletion samples/01.getting-started/b.minimal-bundle/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ Here is the finished `index.html`:
<div id="webchat" role="main"></div>
<script>
(async function() {
const res = await fetch('https://webchat-mockbot.azurewebsites.net/directline/token', { method: 'POST' });
const res = await fetch('https://hawo-mockbot4-token-app.blueriver-ce85e8f0.westus.azurecontainerapps.io/api/token/directline', { method: 'POST' });
const { token } = await res.json();
window.WebChat.renderWebChat(
Expand Down
7 changes: 5 additions & 2 deletions samples/01.getting-started/b.minimal-bundle/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en-US">
<head>
<title>Web Chat: Minimal bundle</title>
Expand Down Expand Up @@ -46,7 +46,10 @@
// Tokens are more secure. To learn about the differences between secrets and tokens
// and to understand the risks associated with using secrets, visit https://docs.microsoft.com/en-us/azure/bot-service/rest-api/bot-framework-rest-direct-line-3-0-authentication?view=azure-bot-service-4.0

const res = await fetch('https://webchat-mockbot.azurewebsites.net/directline/token', { method: 'POST' });
const res = await fetch(
'https://hawo-mockbot4-token-app.blueriver-ce85e8f0.westus.azurecontainerapps.io/api/token/directline',
{ method: 'POST' }
);
const { token } = await res.json();

window.WebChat.renderWebChat(
Expand Down
2 changes: 1 addition & 1 deletion samples/01.getting-started/c.es5-bundle/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ Here is the finished `index.html`:
<div id="webchat" role="main"></div>
<script>
window
.fetch('https://webchat-mockbot.azurewebsites.net/directline/token', { method: 'POST' })
.fetch('https://hawo-mockbot4-token-app.blueriver-ce85e8f0.westus.azurecontainerapps.io/api/token/directline', { method: 'POST' })
.then(function(res) {
return res.json();
})
Expand Down
6 changes: 4 additions & 2 deletions samples/01.getting-started/c.es5-bundle/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en-US">
<head>
<title>Web Chat: Full-featured bundle with ES5 polyfills</title>
Expand Down Expand Up @@ -37,7 +37,9 @@

// This code is modified to run in browser without async and Promise support
window
.fetch('https://webchat-mockbot.azurewebsites.net/directline/token', { method: 'POST' })
.fetch('https://hawo-mockbot4-token-app.blueriver-ce85e8f0.westus.azurecontainerapps.io/api/token/directline', {
method: 'POST'
})
.then(function (res) {
return res.json();
})
Expand Down
4 changes: 2 additions & 2 deletions samples/01.getting-started/e.host-with-react/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ The core of this code both creates and renders the React component that displays

```diff
(async function() {
const res = await fetch('https://webchat-mockbot.azurewebsites.net/directline/token', { method: 'POST' });
const res = await fetch('https://hawo-mockbot4-token-app.blueriver-ce85e8f0.westus.azurecontainerapps.io/api/token/directline', { method: 'POST' });
const { token } = await res.json();
+ const { createDirectLine, ReactWebChat } = window.WebChat;

Expand Down Expand Up @@ -104,7 +104,7 @@ Here is the finished `index.html`:
<div id="webchat" role="main"></div>
<script type="text/babel" data-presets="es2015,react,stage-3">
(async function() {
const res = await fetch('https://webchat-mockbot.azurewebsites.net/directline/token', { method: 'POST' });
const res = await fetch('https://hawo-mockbot4-token-app.blueriver-ce85e8f0.westus.azurecontainerapps.io/api/token/directline', { method: 'POST' });
const { token } = await res.json();
const { ReactWebChat } = window.WebChat;
Expand Down
7 changes: 5 additions & 2 deletions samples/01.getting-started/e.host-with-react/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en-US">
<head>
<title>Web Chat: Integrate with React</title>
Expand Down Expand Up @@ -40,7 +40,10 @@
// Tokens are more secure. To learn about the differences between secrets and tokens
// and to understand the risks associated with using secrets, visit https://docs.microsoft.com/en-us/azure/bot-service/rest-api/bot-framework-rest-direct-line-3-0-authentication?view=azure-bot-service-4.0

const res = await fetch('https://webchat-mockbot.azurewebsites.net/directline/token', { method: 'POST' });
const res = await fetch(
'https://hawo-mockbot4-token-app.blueriver-ce85e8f0.westus.azurecontainerapps.io/api/token/directline',
{ method: 'POST' }
);
const { token } = await res.json();
const { ReactWebChat } = window.WebChat;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ function ChatComponent({ styleOptions }) {
const [directLine, setDirectLine] = useState();

useMemo(async () => {
const res = await fetch('https://webchat-mockbot.azurewebsites.net/directline/token', { method: 'POST' });
const res = await fetch(
'https://hawo-mockbot4-token-app.blueriver-ce85e8f0.westus.azurecontainerapps.io/api/token/directline',
{ method: 'POST' }
);
const { token } = await res.json();

setDirectLine(createDirectLine({ token }));
Expand Down
2 changes: 1 addition & 1 deletion samples/01.getting-started/h.minimal-markdown/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ Here is the finished `index.html`:
<div id="webchat" role="main"></div>
<script>
(async function() {
const res = await fetch('https://webchat-mockbot.azurewebsites.net/directline/token', { method: 'POST' });
const res = await fetch('https://hawo-mockbot4-token-app.blueriver-ce85e8f0.westus.azurecontainerapps.io/api/token/directline', { method: 'POST' });
const { token } = await res.json();
const markdownIt = window.markdownit();
Expand Down
7 changes: 5 additions & 2 deletions samples/01.getting-started/h.minimal-markdown/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en-US">
<head>
<title>Web Chat: Minimal bundle with Markdown</title>
Expand Down Expand Up @@ -46,7 +46,10 @@
// Tokens are more secure. To learn about the differences between secrets and tokens
// and to understand the risks associated with using secrets, visit https://docs.microsoft.com/en-us/azure/bot-service/rest-api/bot-framework-rest-direct-line-3-0-authentication?view=azure-bot-service-4.0

const res = await fetch('https://webchat-mockbot.azurewebsites.net/directline/token', { method: 'POST' });
const res = await fetch(
'https://hawo-mockbot4-token-app.blueriver-ce85e8f0.westus.azurecontainerapps.io/api/token/directline',
{ method: 'POST' }
);
const { token } = await res.json();
const markdownIt = window.markdownit();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ We are updating the endpoint of our token server to retrieve a Direct Line ASE-s

```diff
- const res = await fetch('https://webchat-mockbot.azurewebsites.net/directline/token', { method: 'POST' });
+ const res = await fetch('https://webchat-mockbot2.azurewebsites.net/api/token/directlinease', { method: 'POST' });
- const res = await fetch('https://hawo-mockbot4-token-app.blueriver-ce85e8f0.westus.azurecontainerapps.io/api/token/directline', { method: 'POST' });
+ const res = await fetch('https://hawo-mockbot4-token-app.blueriver-ce85e8f0.westus.azurecontainerapps.io/api/token/directlinease', { method: 'POST' });
```

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en-US">
<head>
<title>Web Chat: Full-featured bundle with Direct Line Speech channel</title>
Expand Down Expand Up @@ -37,18 +37,16 @@
// You should never put the Direct Line secret in the browser or client app.
// https://docs.microsoft.com/en-us/azure/bot-service/rest-api/bot-framework-rest-direct-line-3-0-authentication

const res = await fetch('https://webchat-mockbot3.azurewebsites.net/api/token/directlinease', {
method: 'POST'
});
const res = await fetch(
'https://hawo-mockbot4-token-app.blueriver-ce85e8f0.westus.azurecontainerapps.io/api/token/directlinease',
{ method: 'POST' }
);

const { token } = await res.json();
const { domain, token } = await res.json();

window.WebChat.renderWebChat(
{
directLine: await window.WebChat.createDirectLineAppServiceExtension({
domain: 'https://webchat-mockbot3.azurewebsites.net/.bot/v3/directline',
token
})
directLine: await window.WebChat.createDirectLineAppServiceExtension({ domain, token })
},
document.getElementById('webchat')
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ Here is the finished `index.html`:
<div id="webchat" role="main"></div>
<script nonce="a1b2c3d">
(async function() {
const res = await fetch('https://webchat-mockbot.azurewebsites.net/directline/token', { method: 'POST' });
const res = await fetch('https://hawo-mockbot4-token-app.blueriver-ce85e8f0.westus.azurecontainerapps.io/api/token/directline', { method: 'POST' });
const { token } = await res.json();
window.WebChat.renderWebChat(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en-US">
<head>
<title>Web Chat: Full-featured bundle</title>
Expand Down Expand Up @@ -41,7 +41,10 @@
// Tokens are more secure. To learn about the differences between secrets and tokens
// and to understand the risks associated with using secrets, visit https://docs.microsoft.com/en-us/azure/bot-service/rest-api/bot-framework-rest-direct-line-3-0-authentication?view=azure-bot-service-4.0

const res = await fetch('https://webchat-mockbot.azurewebsites.net/directline/token', { method: 'POST' });
const res = await fetch(
'https://hawo-mockbot4-token-app.blueriver-ce85e8f0.westus.azurecontainerapps.io/api/token/directline',
{ method: 'POST' }
);
const { token } = await res.json();

window.WebChat.renderWebChat(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ Here is the finished `index.html`:
<div id="webchat" role="main"></div>
<script>
(async function() {
const res = await fetch('https://webchat-mockbot.azurewebsites.net/directline/token', { method: 'POST' });
const res = await fetch('https://hawo-mockbot4-token-app.blueriver-ce85e8f0.westus.azurecontainerapps.io/api/token/directline', { method: 'POST' });
const { token } = await res.json();
const styleOptions = {
bubbleBackground: 'rgba(0, 0, 255, .1)',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en-US">
<head>
<title>Web Chat: Custom style options</title>
Expand Down Expand Up @@ -33,7 +33,10 @@
// Tokens are more secure. To learn about the differences between secrets and tokens
// and to understand the risks associated with using secrets, visit https://docs.microsoft.com/en-us/azure/bot-service/rest-api/bot-framework-rest-direct-line-3-0-authentication?view=azure-bot-service-4.0

const res = await fetch('https://webchat-mockbot.azurewebsites.net/directline/token', { method: 'POST' });
const res = await fetch(
'https://hawo-mockbot4-token-app.blueriver-ce85e8f0.westus.azurecontainerapps.io/api/token/directline',
{ method: 'POST' }
);
const { token } = await res.json();

// You can modify the style set by providing a limited set of style options
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ Here is the finished `index.html`:
<div id="webchat" role="main"></div>
<script>
(async function() {
const res = await fetch('https://webchat-mockbot.azurewebsites.net/directline/token', { method: 'POST' });
const res = await fetch('https://hawo-mockbot4-token-app.blueriver-ce85e8f0.westus.azurecontainerapps.io/api/token/directline', { method: 'POST' });
const { token } = await res.json();
const styleSet = window.WebChat.createStyleSet({
bubbleBackground: 'rgba(0, 0, 255, .1)',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en-US">
<head>
<title>Web Chat: Custom style set</title>
Expand Down Expand Up @@ -33,7 +33,10 @@
// Tokens are more secure. To learn about the differences between secrets and tokens
// and to understand the risks associated with using secrets, visit https://docs.microsoft.com/en-us/azure/bot-service/rest-api/bot-framework-rest-direct-line-3-0-authentication?view=azure-bot-service-4.0

const res = await fetch('https://webchat-mockbot.azurewebsites.net/directline/token', { method: 'POST' });
const res = await fetch(
'https://hawo-mockbot4-token-app.blueriver-ce85e8f0.westus.azurecontainerapps.io/api/token/directline',
{ method: 'POST' }
);
const { token } = await res.json();

// You can modify the style set by providing a limited set of style options
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ Here is the finished `index.html`:
<div id="webchat" role="main"></div>
<script>
(async function() {
const res = await fetch('https://webchat-mockbot.azurewebsites.net/directline/token', { method: 'POST' });
const res = await fetch('https://hawo-mockbot4-token-app.blueriver-ce85e8f0.westus.azurecontainerapps.io/api/token/directline', { method: 'POST' });
const { token } = await res.json();
window.WebChat.renderWebChat(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en-US">
<head>
<title>Web Chat: Avatar with initials</title>
Expand Down Expand Up @@ -33,7 +33,10 @@
// Tokens are more secure. To learn about the differences between secrets and tokens
// and to understand the risks associated with using secrets, visit https://docs.microsoft.com/en-us/azure/bot-service/rest-api/bot-framework-rest-direct-line-3-0-authentication?view=azure-bot-service-4.0

const res = await fetch('https://webchat-mockbot.azurewebsites.net/directline/token', { method: 'POST' });
const res = await fetch(
'https://hawo-mockbot4-token-app.blueriver-ce85e8f0.westus.azurecontainerapps.io/api/token/directline',
{ method: 'POST' }
);
const { token } = await res.json();

window.WebChat.renderWebChat(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ Here is the finished `index.html`:
<div id="webchat" role="main"></div>
<script>
(async function() {
const res = await fetch('https://webchat-mockbot.azurewebsites.net/directline/token', { method: 'POST' });
const res = await fetch('https://hawo-mockbot4-token-app.blueriver-ce85e8f0.westus.azurecontainerapps.io/api/token/directline', { method: 'POST' });
const { token } = await res.json();
const styleOptions = {
Expand Down
Loading

0 comments on commit adf280e

Please sign in to comment.