Giter Club home page Giter Club logo

Comments (5)

dochoss avatar dochoss commented on June 9, 2024 1

@derisen I'll be able to get that done on Monday. Don't close this over the weekend! :)

from ms-identity-javascript-v2.

derisen avatar derisen commented on June 9, 2024

@dochoss thank you very much : ) There isn't anything wrong with your code as far as I can see, so I think it would be best if you could send us a Fiddler trace (or any other network trace) and if you have any repository that we could look into that would be great as well. Please send them over mail to v-doeris at microsoft com.

from ms-identity-javascript-v2.

derisen avatar derisen commented on June 9, 2024

@dochoss any updates on this?

from ms-identity-javascript-v2.

derisen avatar derisen commented on June 9, 2024

Closing due to inactivity.

from ms-identity-javascript-v2.

pavandev-lab avatar pavandev-lab commented on June 9, 2024

HI Team,

I am facing similar issue, token is generated but still i am facing same issue (401 even with a valid token)

Below is my code

export const getAuthToken = async () => {
 const msal = require("@azure/msal-node");
//  const msal = require("@azure/msal-browser");

const msalConfig = {
    auth: {
        clientId: "ClientID",
        authority: Authority,
        clientSecret: "clientSecret",
        navigateToLoginRequestUrl: false
    },
    cache: {
        // your implementation of caching
        cacheLocation: "sessionStorage", // This configures where your cache will be stored
        storeAuthStateInCookie: false, // Set this to "true" if you are having issues on IE11 or Edge
    },
    system: {
        loggerOptions: { /** logging related options */ }
    }
};

const cca = new msal.ConfidentialClientApplication(msalConfig);
//const myMSALObj = new msal.PublicClientApplication(msalConfig);
const usernamePasswordRequest = {
//scopes: ["user.read"],
username: EnvVariables.OrgAdminUserName, // Add your username here
password: EnvVariables.OrgAdminPassword, // Add your password here
};
// await myMSALObj.acquireTokenWithUsernamePassword
const accessToken = await cca.acquireTokenByUsernamePassword(usernamePasswordRequest).then((response) => {
console.log("acquired token by password grant in confidential clients");
return response.accessToken;
}).catch((error) => {
console.log(error);
});
};

 //token passing to the axios Get call
 export const ExecuteGetRequest = async (getUrl: string) => {
const token = await getAuthToken();
return await axiosDefault.get(getUrl, {
    headers: {
        "Authorization": `Bearer ${token}`,
        "Content-Type": "application/json",
    },
});

};

from ms-identity-javascript-v2.

Related Issues (18)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.