mirror of
https://github.com/usebruno/bruno.git
synced 2026-07-07 22:18:33 +00:00
fix(bru-1928): bruno-cli oauth2 updates (#5729)
This commit is contained in:
33
packages/bruno-cli/src/utils/oauth2.js
Normal file
33
packages/bruno-cli/src/utils/oauth2.js
Normal file
@@ -0,0 +1,33 @@
|
||||
const { getOAuth2Token: _getOAuth2Token } = require('@usebruno/requests');
|
||||
const tokenStore = require('../store/tokenStore');
|
||||
const { getOptions } = require('./bru');
|
||||
|
||||
/**
|
||||
* Formats OAuth2 credentials into variables that can be accessed via bru.getOauth2CredentialVar()
|
||||
* @returns {Object} Formatted OAuth2 credential variables
|
||||
*/
|
||||
const getFormattedOauth2Credentials = () => {
|
||||
const oauth2Credentials = tokenStore.getAllCredentials();
|
||||
let credentialsVariables = {};
|
||||
|
||||
oauth2Credentials.forEach(({ credentialsId, credentials }) => {
|
||||
if (credentials) {
|
||||
Object.entries(credentials).forEach(([key, value]) => {
|
||||
credentialsVariables[`$oauth2.${credentialsId}.${key}`] = value;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return credentialsVariables;
|
||||
};
|
||||
|
||||
const getOAuth2Token = (oauth2Config) => {
|
||||
let options = getOptions();
|
||||
let verbose = options?.verbose;
|
||||
return _getOAuth2Token(oauth2Config, tokenStore, verbose);
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
getFormattedOauth2Credentials,
|
||||
getOAuth2Token
|
||||
};
|
||||
Reference in New Issue
Block a user