My scenario is I have to encode the token and secret using base encoding then generate a JWT token through API, which will give response like:
eyJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJmOWJlYmFjYjVhMjE0M2FiYTE1ZWFlMDUyNGFlMjFhYiIsImV4cCI6MTUwOTYwNDQ5OSwianRpIjoiN256WlhqQW9yd2FEVmxnSUZSZHJLQSIsImlhdCI6MTUwOTYwNDQ4NCwibmJmIjoxNTA5NjA0MzY0LCJzdWIiOiJmOWJlYmFjYjVhMjE0M2FiYTE1ZWFlMDUyNGFlMjFhYiJ9.0QCtE5XF-_FxxhjpP2sIEFU8rSnNK5jwD3BBd5oCUGc
Then we have to use this in headers for rest of the API call like:
function() {
var out = {
'Authorization': 'Bearer eyJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJlNjhjODJhNjY1MTQ0ZmRkOTk5YzU1MjExYjYyODQ3YyIsImV4cCI6MTUwMjk3NjEzNSwianRpIjoiUm1VeFdDNWhQQXdvNVZ0TXFYeEFlQSIsImlhdCI6MTUwMjk3NjEyMCwibmJmIjoxNTAyOTc2MDAwLCJzdWIiOiJlNjhjODJhNjY1MTQ0ZmRkOTk5YzU1MjExYjYyODQ3YyJ9.h3buTcq-KATXuDF6SEdA5rblvTI84_SuDZPOqdm4j7Q',
'Content-Type': 'application/json'
};
return out;
}
So how to integrate this to make this header generic for rest of the API calls?