Microsoft Teams Custom App doesn't work on Android mobile - android

I'm testing the custom tab on Microsoft Teams app.
It correctly works on Desktop and iPhone, but it doesn't work on the Android mobile app.
The Android mobile debug screenshot
I'd like to know Why it's canceled?
The Android mobile couldn't open the app's web page.
I've captured the packet on the webserver when the android clicked the custom tab.
I could see only the server key exchange process, there is no client key exchange.
Android mobile
The iPhone was working properly and there was the client key exchange process.
iPohne
Please advise me.
Refferred to the below source code:
const express = require('express');
const bodyParser = require('body-parser');
const cors = require('cors');
const morgan = require('morgan');
const env = require('node-env-file');
const path = require('path');
var cookieParser = require('cookie-parser');
env(path.join(__dirname, '../.env'));
const config = require('./config/config');
const { logger } = require('./logger/logger');
const fs = require('fs');
const https = require('https');
const nocache = require('nocache');
const app = express();
const api = require('./api');
app.use(morgan('combined'));
app.enable('trust proxy');
app.use(bodyParser.json({ limit: '5mb' }));
app.use(bodyParser.urlencoded({ limit: '5mb', extended: true, parameterLimit: 50000 }));
app.use(cors());
app.use(nocache());
app.use(cookieParser())
app.use('/api', api);
// Login Authenticate
if (config.loginMode === 'local') {
require('./passport')
}
if (process.env.NODE_ENV === 'production') {
// Vue Router
app.use(require('connect-history-api-fallback')());
app.use(express.static(path.join(__dirname, '../../dist')));
}
// MongoDB Connection
require('./db')
const options = {
key: fs.readFileSync('./keys/evm.ecstel.co.kr.key', 'utf8'),
cert: fs.readFileSync('./keys/evm_ecstel_co_kr.crt', 'utf8')
}
// Server Running
const server = https.createServer(options, app).listen(process.env.PORT || config.port, function () {
logger.info(`Server started on https`)
logger.info(`Server started on port ${config.port} in ${config.host}`)
})

Related

Having issue regarding the socket in my server and the client side android application

we are trying to connect the socket through https server and that was working perfectly fine few days back after that our ssl certificate expire on the server so we just use Let's encrypt to get the free ssl for our server and after that we ran into trouble.
And also we are using socket with socket.io-redis
package version in nodejs:-
"socket.io": "^1.7.3",
"socket.io-redis": "^4.0.0",
package version in android:-
io.socket:socket.io-client:0.8.3
our application is not connecting from the socket rest everthing is working fine.
one application we are getting the error of;
io.socket.engineio.client.EngineIOException: xhr poll error
Also i am providing the server side code please help me as soon as possible
backend in nodejs
client side android (application)
nodejs code
var https = require("https");
var server = https.createServer({
key: fs.readFileSync(process.env.SSL_KEY),
cert: fs.readFileSync(process.env.SSL_CERT),
}, app);
} else {
var server = http.createServer(app);
}
global.io = require('socket.io')(server,{ rejectUnauthorized: false });
var redis = require('socket.io-redis');
io.adapter(redis({
host: 'localhost',
port: 6478,
}));
io.on('connection', function (socket) {
console.log('...........................socket connected', socket);
}); ```
Please follow this demo code for setup socket io with node and express this may help you to fix your issue
const express = require('express');
const app = express();
const http = require('http');
const server = http.createServer(app);
const { Server } = require("socket.io");
const io = new Server(server);
app.get('/', (req, res) => {
res.sendFile(__dirname + '/index.html');
});
io.on('connection', (socket) => {
console.log('a user connected');
});
server.listen(3000, () => {
console.log('listening on *:3000');
});

api request does not work in react-native

i'm using react-native
When I run the emulator virtually the api is well requested to the backend router.
However, when I actually test it on my Android device, the api request does not reach the backend.
My front port number is 8081 and my back end is 3065.
this is my code
for example my ip address: 49.174.243.53
(front.js)
const Kakao = ({navigation}) => {
const hello = async () => {
const {data} = await axios.post('http://43.164.243.53:3065/kakao/test', {
hi: 'hi2',
});
};
return (
<LoginButton style={{marginTop: 30}} onPress={hello}>
<Label>hello</Label>
</LoginButton>
);
};
export default Kakao;
(back/app.js)
const express = require('express');
const dotenv = require('dotenv');
const morgan = require('morgan');
const path = require('path');
const kakaoRouter = require('./routes/kakao');
const db = require('./models');
dotenv.config();
const app = express();
db.sequelize
.sync()
.then(() => {
console.log('db 연결 성공');
})
.catch(console.error);
passportConfig();
app.use(morgan('dev'));
app.use('/', express.static(path.join(__dirname, 'uploads')));
app.use(express.json());
app.use(express.urlencoded({extended: true}));
app.get('/', (req, res) => {
res.send('hello express');
});
app.use('/kakao', kakaoRouter);
app.listen(3065, () => {
console.log('서버 실행 중!');
});
(back/router)
router.post('/test', async (req, res, next) => {
//whic is kakao/test
try {
console.log('req.body:::::::::', req.body);
return res.status(200).json({
posts: 'h!!!!!!!!!!!!!!!!!',
});
} catch (error) {
next(error); // status 500
}
});
In order to view remote documents from an HTTP URL, cleartext network traffic support is required. On Android 9.0 (API level 28) or higher, cleartext support is disabled by default and apps targeting Android 9.0 or higher will need to add the android:usesClearTextTraffic="true" flag in the AndroidManifest.xml file.
If you are only working with HTTPS files, this flag is not required

Ionic 5 - Can't display data from API

Note: Total Ionic newbie here.
I have the following:
Ionic 5 (Capacitor) app with Angular 11.
Express backend (localhost:3000)
I can fetch data from an API call and display in the browser, but not on the emulated Android device. I don't know how to check for console errors in Android Studio.
This image can explain the situation better.
I think this is due to CORS. I tried to follow the Ionic page on this but no resolution.
Here is my Express code:
const express = require("express");
const cors = require("cors");
const app = express();
const port = 3000;
const allowedOrigins = [
"capacitor://localhost",
"ionic://localhost",
"http://localhost",
"http://localhost:8080",
"http://localhost:8100",
"http://192.168.2.25:8100",
];
// For parsing JSON in request body
app.use(express.json());
// MySQL connection details - for POC sake.
// In PROD, these are typically saved in .env variables
// Ref: https://www.linkedin.com/pulse/storing-database-credentials-securely-siddhesh-jog
var mysql = require("mysql");
var connection = mysql.createConnection({
host: "____________________________.us-east-2.rds.amazonaws.com",
user: "admin",
password: "*****************",
database: "poc",
});
const corsOptions = {
origin: (origin, callback) => {
if (allowedOrigins.includes(origin) || !origin) {
callback(null, true);
} else {
console.log(origin);
callback(new Error("Origin not allowed by CORS"));
}
},
};
// Enable preflight requests for all routes
app.options("*", cors(corsOptions));
// Connect to MySQL
connection.connect(function (err) {
if (err) throw err;
console.log("Connected!");
});
// Dashboard - GET
app.get("/dashboard", cors(corsOptions), (req, res) => {
rows = [];
connection.query(
"select label_id, value from poc_fct",
function (err, result) {
if (err) throw err;
res.json(result);
}
);
});
app.listen(port, () => {
console.log(`CORS-enabled web server listening at http://localhost:${port}`);
});
Any help will be greatly appreciated.
What finally worked for me was changing the API endpoint from http://localhost:3000/data to http://192.168.2.25:3000/data, where 192.168.2.25 is the local IP address of the host where the Express server is running.
Few notes for anyone else who might have this issue in the future:
This isn't a CORS issue. I commented out app.use(cors)
This isn't a HTTP/HTTPS issue
Changing the emulator's proxy to 10.0.2.2:3000 did not work

Using Azure KeyVault for React Native

I am not using Azure Active Directory authentication in my React Native application.
I want to keep some keys on the cloud so that a user can easily configure without redeploying the complete application.
I was thinking about Azure KeyVault, so the question is, is it possible to use key vault, can I do without showing the authentication page.
If there is any other solution for this let me know.
You can use script code to get the value of the key. Don't need to showing the authentication page.
Below is a simple console code:
//const { DefaultAzureCredential } = require("#azure/identity");
const { ClientSecretCredential } = require("#azure/identity");
const { SecretClient } = require("#azure/keyvault-secrets");
const readline = require('readline');
function askQuestion(query) {
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
});
return new Promise(resolve => rl.question(query, ans => {
rl.close();
resolve(ans);
}))
}
async function main() {
const keyVaultName = "bowmantest";
const KVUri = "https://" + keyVaultName + ".vault.azure.net";
//const credential = new DefaultAzureCredential();
tenantId = "e4c9ab4e-bdxxxxxx-230ba2a757fb";
clientId = "d340361e-5dxxxxxxbaf4-6e81aed46ed9";
clientSecret = "2X~43qA-~J2xxxxxxnT1a7_O2-dKyTK";
const credential = new ClientSecretCredential(tenantId, clientId, clientSecret);
const client = new SecretClient(KVUri, credential);
const secretName = "testbowmansecret";
console.log("Retrieving your secret from " + keyVaultName + ".");
const retrievedSecret = await client.getSecret(secretName);
console.log("Your secret is '" + retrievedSecret.value + "'.");
}
main()
And I can get: (don't need to go to authentication page, but authentication is still needed.)
By the way, you need to give the AD app the access permission:
This is the api documentation:
https://learn.microsoft.com/en-us/javascript/api/#azure/identity/clientsecretcredential?view=azure-node-latest
https://learn.microsoft.com/en-us/javascript/api/%40azure/keyvault-secrets/secretclient?view=azure-node-latest
(You can find everything about JavaScript with Azure in above documentation).

Create authentication ticket for Sinch Android And IOS client (Nodejs)

I am facing problem in creating the Sinch auth ticket for Android and IOS client using Nodejs. I tried sinch-ticketgen NPM module but it is generating tickets for javascript only, we can not use this ticket for Android and IOS clients.
Following is the code snippet I am using for the ticket generation but it is not working,
const crypto = require('crypto');
const shasum = crypto.createHash('sha1');
const key = '0b25bb2d-f5dd-4337-9f99-a318196f886a';
const secret = 'm1aur2Q4FUWWNuMlKq3KKg==';
const userId = 'sanket';
const sequence = 0;
const stringToSign = userId + key + sequence + secret;
shasum.update(stringToSign);
const singnature = shasum.digest('utf8'); //utf8
console.log('Signature ', singnature.toString('base64'));
const token = singnature.toString('base64').trim();
console.log(token);
Pseducode for the ticket generation is given in the https://www.sinch.com/docs/voice/ios/#applicationauthentication
I tried java example its working fine, not getting where I am making mistake in Nodejs ticket creation.
Following is the working Nodejs snippet for it.
const crypto = require('crypto');
const shasum = crypto.createHash('sha1');
const key = '0b25bb2d-f5dd-4337-9f99-a318196f886a';
const secret = 'm1aur2Q4FUWWNuMlKq3KKg==';
const userId = 'sanket';
const sequence = 0;
const stringToSign = userId + key + sequence + secret;
shasum.update(stringToSign);
const singnature = shasum.digest();
console.log('Signature ', singnature.toString('base64'));
const token = singnature.toString('base64').trim();
console.log(token);

Categories

Resources