MsalException: Applicationis not configured as a multi-tenant application. Android - android

My Android app is using MSAL with this guide azure
When I try to sign up I get this error
MsalException: Applicationis not configured as a multi-tenant application. Usage of the /common endpoint is not supported for such applications created after '10/15/2018'. Use a tenant-specific endpoint or configure the application to be multi-tenant.
Now i don't want to configure the application to be multi-tenant. so that leaves me with the second option of
Use a tenant-specific endpoint
From what I've seen I need to add it to the msal.config file which now looks like this :
{
"client_id" : "my cli id",
"redirect_uri" : "my red uri",
"broker_redirect_uri_registered": true,
"account_mode": "MULTIPLE",
"authorities" : [
{
"type": "AAD",
"audience": {
"type": "AzureADandPersonalMicrosoftAccount"
}
}
]
}
now this doesn't have an effect , I also understand I need to put somewhere the url of the endpoint with the tennant id and it takes /common as default ,
Any one have any ideas or example of how to do that ?
Thanks all

In the "audience", change the "type" to "AzureADMyOrg" and add "tenant_id" after that like below.
{
"client_id" : "my cli id",
"redirect_uri" : "my red uri",
"broker_redirect_uri_registered": true,
"account_mode": "MULTIPLE",
"authorities" : [
{
"type": "AAD",
"audience": {
"type": "AzureADMyOrg",
"tenant_id": "org_tenant_id"
}
}
]
}

Related

MSAL with EWS for Android gives Need admin approval

I try to change an authentication method from basic to oAuth for Android app. So I decided to use MSAL library, registered an app to Azure App registration, added Android to authentication platform config and added "EWS.AccessAsUser.All" permission in "Office 365 Exchange Online" group.
Here is how my config looks like:
{
"client_id" : "MY_CLIENT_ID_HETE",
"authorization_user_agent" : "DEFAULT",
"redirect_uri" : "msauth://com.testing.testauth/MY_KEY_HASH_HETE",
"authorities" : [
{
"type": "AAD",
"audience": {
"type": "AzureADandPersonalMicrosoftAccount",
"tenant_id": "common"
}
}
]
}
In android app for scopes I use [https://outlook.office365.com/EWS.AccessAsUser.All].
Here is the code how I use auth lib:
PublicClientApplication.createMultipleAccountPublicClientApplication(this,
R.raw.msal_config,
object : IMultipleAccountApplicationCreatedListener {
override fun onCreated(application: IMultipleAccountPublicClientApplication) {
}
override fun onError(exception: MsalException) {
}
})
}
After that when trying to log in, entering email and password I receive notification "Need admin approval" with message "AADSTS900941: This operation can only be performed as administrator".
Any ideas what am I doing wrong? Thanks in advance.

Getting 500 - Internal Error Encountered with Youtube Broadcast Insert API

I am trying to insert a LiveBroadcast using Youtube LIVE streaming API.
Here is my request which I made on the API playground on youtube API docs.
POST https://www.googleapis.com/youtube/v3/liveBroadcasts?part=snippet%2C%20id%2C%20status%2C%20contentDetails&key=[YOUR_API_KEY] HTTP/1.1
Authorization: Bearer [YOUR_ACCESS_TOKEN]
Accept: application/json
Content-Type: application/json
{
"contentDetails": {
"enableClosedCaptions": true,
"enableEmbed": true,
"enableLowLatency": true,
"recordFromStart": true,
"enableAutoStart": true,
"enableAutoStop": true
},
"status": {
"privacyStatus": "public",
"selfDeclaredMadeForKids": true,
"liveBroadcastPriority": "high",
"madeForKids": true
},
"snippet": {
"title": "My broadcasst",
"description": "My Description",
"scheduledStartTime": "2020-06-177T03:48:46.46Z",
"scheduledEndTime": "2020-06-178T11:48:52.52Z"
}
}
And the response that I am getting is
{
"error": {
"code": 500,
"message": "Internal error encountered.",
"errors": [
{
"message": "Internal error encountered.",
"domain": "global",
"reason": "backendError"
}
],
"status": "INTERNAL"
}
}
Any help will be appreciated. Thanks in advance
The error was with the time format string that I had copied from google docs for ISO-8601 format, mentioned for all their time-relatedfields. I suggest creating your format string from here for java code
According to the docs, you're not supposed to provide the makeForKids property (that's the job of the API).
When calling for liveBroadcasts.insert endpoint, if wanting to designate the respective broadcast as child-directed, you should use this property instead:
status.selfDeclaredMadeForKids (boolean)
In a liveBroadcasts.insert request, this property allows the channel owner to designate the broadcast as being child-directed. In a liveBroadcasts.list request, the property value is only returned if the channel owner authorized the API request.
The other properties that you shouldn't have set are enableLowLatency and liveBroadcastPriority.

Where to find the components key in the link of execute command of azure iot central

**[11:12] Umer Saleem
Working on it, sir in this example link what is the components name and how to find it
POST https://{subdomain}.{centralDnsSuffixInPath}/api/preview/devices/{device_id}/components/{component_name}/commands/{command_name}
**
To find out what components you have for this device, you can do a GET request to
https://{subdomain}.{centralDnsSuffixInPath}/api/preview/devices/{device_id}/components/
This will show you the components, a sample response can be:
{
"value": [
{
"#id": "urn:machine:MyMachine:lxhc64xu:1",
"#type": [
"InterfaceInstance"
],
"name": "cb_7d7",
"displayName": "Interface"
},
{
"#id": "urn:machine:MyMachine:_lyh_e2x:1",
"#type": [
"InterfaceInstance"
],
"name": "cb_282",
"displayName": "Properties"
}
]
}
The name of the {component} is the name of the value that you get in the response. In my example, you can use "cb_7d7" or "cb_282". They are the names of your interfaces.

Firebase Cloud Messaging notification per OS type (iOS/Android/Web) usage

We are implementing FCM in our iOS, Android and web apps and saw that the documentation speaks about sending different values to different OS types via ApnsConfig, WebpushConfig and AndroidConfig objects (https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages)
We tried all kinds of variations but we just can't get this to work. Does anybody know what we are doing wrong? Here is a example of how we try to send something:
{
"notification" : {
"title" :"Title",
"body": "Body",
}
"data" : {
"all_devices_key" : "all_devices_value",
}
"content_available": true,
"to": "...",
"apns": {
"headers": {
"ios_only_key": "ios_only_value",
},
}
}
We also tried the payload and other combinations in the apns like the following but nothing ever comes through.
"apns": {
"payload": {
"ios_only_key": "ios_only_value",
"aps" : {
"alert" : {
"title" : "Game Request",
"body" : "Bob wants to play poker",
"action-loc-key" : "PLAY"
},
"badge" : 5
},
"acme1" : "bar",
"acme2" : [ "bang", "whiz" ]
},
}
Are we misunderstanding the documentation? How can we send specific key-value-pairs to only iOS or Android or Web?

Firebase realtime database structure in chat app

sorry for my bad English level, I'm from Argentina.
I have the following messages data structure in Firebase:
"messages"
"-KezmqXSdKCNFFA432Uc___-KfCEwklG_y3naRDIUiY"
"messageDate": "20170620"
"messageTime": "18:44"
"message": "Hi"
"-KezFDSAADFASFFS3221___-KASDF32324SDFASD1FS"
"messageDate": "20170620"
"messageTime": "22:23"
"message": "How are you?"
Where -KezmqXSdKCNFFA432Uc, -KfCEwklG_y3naRDIUiY, -KezFDSAADFASFFS3221 and -KASDF32324SDFASD1FS are users.
My problem is that I created a childEventListener in "messages" node to receive new users messages but I am receiving all the new messages of all the users (I'm logged in one user per app) because my childListener is in "messages" node.
Is it correct that if I have 1000 users when adding a message, a new message reaches the 1000 users? (Assuming that within the app, you can check to which user that message belongs).
Thanks!
If you do a structure like similar to this:
-chats
- chatUID
- members
- userUID
- lastMessageSent:messageUID
- ... more properties
-chatMessages
- chatUID
- messageUID
- sentBy: userUID
- messageDate:""
- messageTime:""
- message:""
-userChats
- userUID
- chatUID
you can attach a listener to /userChats/userUID, which will display active chats, and a listener to /chatMessages/chatUID, which will get all chat messages for a specific chat conversation.
This way is a lot easier to setup firebase security rules, and users will only receive chat messages which they are apart of.
Thanks to #Linxy for a brilliant answer
I have created a firebase database regarding #Linxy answer
Here is the complete JSON export
{
"Chats" : {
"-Lsfsd234xda" : {
"lastMessageSent" : "-LrDEBo1-Message",
"members" : [ "-LrDEBoLokW-5mhaT3ys", "-LrDEBoLokW-5mhaT3yz" ],
"more_properties" : "goes here"
}
},
"Users" : {
"-LrDEBoLokW-5mhaT3ys" : {
"id" : "-LrDEBoLokW-5mhaT3ys",
"userDisplayName" : "Qadir Hussain",
"userEmail" : "XXXXX.XXXX#gmail.com",
"userPhotoUrl" : "https://lh3.googleusercontent.com/a-/AAuE7XXXXXXXXX"
},
"-LrDEBoLokW-5mhaT3yz" : {
"id" : "-LrDEBoLokW-5mhaT3yz",
"userDisplayName" : "Ishaq Bhojani",
"userEmail" : "XXXXXXX.XXXXXX#gmail.com",
"userPhotoUrl" : "https://lh3.googleusercontent.com/a-/AAuE7mB3KTbXXXXXXXX"
}
},
"chatMessages" : {
"-Lsfsd234xda" : {
"-LrDEBo-MessageUID" : {
"message" : "Hi there!",
"messageDate" : "10/10/2019",
"messageTime" : "10:16pm",
"sentBy" : "-LrDEBoLokW-5mhaT3ys"
},
"-LrDEBo1-MessageUID" : {
"message" : "Hello",
"messageDate" : "10/10/2019",
"messageTime" : "10:17pm",
"sentBy" : "-LrDEBoLokW-5mhaT3yz"
}
}
},
"userChats" : {
"-LrDEBoLokW-5mhaT3ys" : {
"0" : "-Lsfsd234xda",
"1" : "-Lsfsd234xda1",
"chatUID" : "-Lsfsd234xda"
}
}
}
I know it's late to answer but for future readers although Linxy's answer is neater, I would like to point out a more efficient one having been tried both structures:
ChatMessages
smallerUID_biggerUID
messageUID
sentBy : userUID
messageDate : ""
message : ""
.
.
.
.
UserChats
userUID
pairUID
lastMessage : ""
.
.
.
.
In this way, instead of first finding out the chatId then finding out which user is associated with that chatId, we can directly search which users should appear in our active chat tab and get thouse users' information (username, profilePicture). The reason for that is we can always calculate the chatId if we know the user's id we would like to message with. So for the message tab, we calculate the chatId (smallerUID_biggerUID) in client side and search for the messages in referencing it.
In order to structure your database, please read this post: Structuring your Firebase Data correctly for a Complex App. You'll find here for sure the answer to your question.
As a conclusion, try to flatten(denormalize) your database as much as possible.
Hope it helps.
this structure doesn't support what you want to do, it better to change it by using something like channels, where a channel contains the messages between two persons, so when any one of them send a message the other one will be notified.
{
"users": {
"userId": {
"conversations": {
"conversationId": {
"unseenCount": 0
},
"conversationId2": {
"unseenCount": 3
}
}
},
"conversations": {
"conversationId": {
"displayedMessage": "Message",
"members": {
"userId1": true,
"userId2": true
},
"messages": {
"messageId": {
"type": "text",
"text": "Hello",
"createdAt": "",
"senderId": "userId",
"status": "sent",
"payload": ""
}
},
"lastMessage": "my last message"
}
}
}
I think this will be the best structure for it:
{
messages: {
A8Fcn28ak9ask46: {
chat_id: "combination of sender and receivers number",
sender_id: "person sending the message",
receiver_id: "person send it to",
text: "message that the user types",
timestamp: "123981849404"
},
...
}
}
then when u get the results, you can filter through the chat_id's in forward and in reverse, which will get the conversation between two people.
Hope it helps.

Categories

Resources