NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

import axios from 'axios';

// Defining the token response type according to your OAuth provider's response format
interface TokenResponse {
access_token: string;
token_type: string;
expires_in: number;
scope: string;
}

// Defining the function to get the access token
export async function getAccessToken(): Promise<TokenResponse> {
const tokenEndpoint = 'https://login.microsoftonline.com/8be8e238-f32a-4b1b-b02e-44d1b7db4632/oauth2/v2.0/token'; // Replace with your auth server's token endpoint

const headers = {
'Content-Type': 'application/x-www-form-urlencoded',
'Access-Control-Allow-Origin':'http://localhost:3000',
};

// const params = new URLSearchParams();
// params.append('grant_type', 'client_credentials');
// params.append('client_id', process.env.REACT_APP_APIM_Client_ID!);
// params.append('client_secret', process.env.REACT_APP_APIM_Client_Secret!);
// params.append('scope', process.env.REACT_APP_APIM_Scope!);

// try {
// const response = await fetch(tokenEndpoint, {
// method: 'POST',
// //mode: 'no-cors',
// headers: {
// 'Content-Type': 'application/x-www-form-urlencoded',
// 'Access-Control-Allow-Origin':'http://localhost:3000',
// 'Access-Control-Allow-Credentials': 'true',
// 'Access-Control-Allow-Headers' : 'x-requested-with, Content-Type, origin, authorization, accept, client-security-token',
// 'Access-Control-Allow-Methods' : 'GET,POST,OPTIONS,PUT,PATCH,DELETE',
// },
// body: {
// 'grant_type': 'client_credentials',
// }
// });

// if (!response.ok) {
// throw new Error(`HTTP error! status: ${response.status}`);
// }

// const data: TokenResponse = await response.json();
// return data;
// } catch (error) {
// console.error('Error fetching access token:', error);
// throw error;
// }

const body = {
grant_type: 'client_credentials',
client_id: process.env.REACT_APP_APIM_Client_ID!,
client_secret: process.env.REACT_APP_APIM_Client_Secret!,
scope: process.env.REACT_APP_APIM_Scope!,
};

try {
const response = await axios.request<TokenResponse>({
url: tokenEndpoint,
method: 'POST',
headers: headers,
data: body,
});
// const response = await axios.post<TokenResponse>(tokenEndpoint, params, {
// headers
// });
return response.data;
} catch (error) {
console.error('Error fetching access token:', error);
throw error;
}
}


import { getAccessToken } from "../components/auth/tokenService";
const { setFirstFunctionResponse, setSecondFunctionResponse, setFeedbackResponse } =
useAppContext();
// const [token, setToken] = useState<string | null>(null);
// const [error, setError] = useState<string | null>(null);

// const handleGetToken = async () => {
// try {
// const response = await getAccessToken();
// setToken(response.access_token);
// } catch (err) {
// setError('Failed to fetch access token');
// console.log("Access Token APIM error: ",error);
// }
// };

// handleGetToken();

REACT_APP_Authority_URL=https://login.microsoftonline.com/8be8e238-f32a-4b1b-b02e-44d1b7db4632
REACT_APP_Client_ID=6aa9a6bd-e840-4a44-871d-ee0ca5029150
REACT_APP_Ocp_Apim_Subscription_key=ff37bf63f15547628458f4a3d6aeffe8
REACT_APP_Apim_Url=https://devapimgateway.corp.tmnas.com/api-00-dv-waiverreviewopenai-001
REACT_APP_Redirect_URL=http://localhost:3000
REACT_APP_AzureFunction_URL=https://fap-00-openai-dev-001.azurewebsites.net/api
REACT_APP_APIM_Client_ID=546a3903-eae5-4383-bd33-7fd3f8927538
REACT_APP_APIM_Client_Secret=H4Z8Q~2yaAtuQ_Ckpzk.oH3KmVBCuFYWe8TfPcSm
REACT_APP_APIM_Scope=api://2b671c55-a28f-481d-aada-832718765d79/.default
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.