In XMPP framework when i am try to add user in my roster with Nick name at that time user added in my roster but nick name not set in my roster list for that user.
Code : Swift 3.0 ,
Server : ejabberd
Snippets of code :
self.xmppRoster.addUser(phJID, withNickname: strName)
self.xmppRoster!.acceptPresenceSubscriptionRequest(from: phJID, andAddToRoster: true)
if i have tried manually and then i have received below error message.
self.xmppRoster.setNickname(strName, forUser: phJID)
Error Msg :
<iq xmlns="jabber:client" type="error"><query xmlns="jabber:iq:roster"><item jid="2323232323#ServerIP"/></query><error code="400" type="modify"><bad-request xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/><text xmlns="urn:ietf:params:xml:ns:xmpp-stanzas" lang="en">Missing attribute 'id' in tag <iq/> qualified by namespace 'jabber:client'</text></error></iq>
Below Stack Question i have checked.
1) ejabberd can not set nickname when add roster sometimes
Help is needed.
Related
In my play-framework application, there is a messages file which I can use to define my own messages. Eg
##############Application Error messages
error.incorrectBodyType=Incorrect body type. Body type must be JSON
error.incorrectBodyContentInLoginRequest=No Login info found in the request. Check format
error.incorrectUsernameOrPassword = Incorrect username or password
error.unregisteredUser = registration not complete
error.ghostUsername = No record found for the username
error.unauthenticated = You must first sign in
error.unauthorized = You are not permitted
####### Application Success Messages
success.signoutSuccessful = Signout Successful
The play frameworks makes these messages available to my Controller and I can use them like the messagesApi("error.unauthenticated")(langs.availables(0)).
I am unable to figure out how I can use the messages file in my unit tests. I am using compile time injection and am creating my own instances of the required classes. To create MessagesApi, there is a DefaultMessagesApi method but it take a map, not a File.
I am able to create the messages in my unit tests as follows but I have to duplicate the effort of copying messages from messages file to this map
val messagesApi = new DefaultMessagesApi( //takes map of maps. the first is the language file, the 2nd is the map between message title and description
Map("en" -> //the language file
Map("error.incorrectBodyType" -> "Incorrect body type. Body type must be JSON",
"error.incorrectUsernameOrPassword"->"Incorrect username or password",
"error.incorrectBodyContentInLoginRequest"->"No Login info found in the request. Check format", //map between message title and description
"error.unregisteredUser" -> "registration not complete",
"error.ghostUsername" -> "No record found for the username",
"success.signoutSuccessful" -> "Signout Successful",
"error.unauthenticated" -> "You must first sign in",
"error.unauthorized" -> "You are not permitted")
)
)
Is there a way I can read the messages file and use it in my test case?
My test case already extended OneAppPerSuiteWithComponents. I used components.messagesApi of OneAppPerSuiteWithComponents which was already available and reads from the messages file
I want to create a simple chat app demo using pusher chat kit.
I am following the pusher provided tutorial .I am following documentation as it is but its not working in my case .
According to pusher documentation Chatmanger class object should be instantiated as follow:
chatManager = ChatManager(
instanceLocator: "YOUR INSTANCE LOCATOR",
tokenProvider: PCTokenProvider(url: "YOUR TEST TOKEN ENDPOINT"),
userId: "YOUR USER ID"
)
but in my case when i follow same code in my demo project there is an error appeared with following parameter correction Error .
I don't know Where i am doing wrong .
What you have to do is create an account in https://pusher.com/, and then create
and a chatkitt instance.
Now you have an account and chatkit instance. To acces The chatkit instance from your .js using:
const chatkit = new Chatkit.default({
instanceLocator: "PUSHER_CHATKIT_INSTANCE_LOCATOR",
key: "PUSHER_CHATKIT_KEY"
})
PUSHER_CHATKIT_INSTANCE_LOCATOR: it's a string that you can see in pusher inside your account, it's a unique.
Additionally, you have the PUSHER_CHATKIT_KEY it's string and unique too.
both them (PUSHER_CHATKIT_INSTANCE_LOCATOR, and key), has to replace in the code above by the strings provided in your account.
i will leave you the tutorial about this step in this link:
https://pusher.com/tutorials/chat-widget-javascript#create-your-chatkit-instance
How to import a dashboard from one server to other?
I tried and downloaded the dashboard JSON file and imported it the other TB server, and gave the alias names.
But, the devices and the assets and other entities and its states did not get imported.
Am I doing it wrong?
Are the other devices and the assets and other entities , need to be imported seperately? How?
Thanks
when you import a dashboard you just import its configuration not the telemetries and attributes and value of them . try to import dashboard then see what entity it wants then go and define an entity for example define a device and use thingsboard telemetry upload api to send needed telemetries to device and their value (try in postman). then go to dashboards edit mode and select your own entities sent before . for example :
send a request to http(s)://host:port/api/v1/$ACCESS_TOKEN/telemetry
request body something like this :
{ "temperature": 456 ,
"humidity" : 700 ,
"energy" : 78444 ,
"water" : 12344 ,
"address" : "Iran, Tehran, 3 District"
}
Gmail API fails for one domain when retrieving messages with this error:
com.google.api.client.googleapis.json.GoogleJsonResponseException: 403 OK
{
"code" : 403,
"errors" : [ {
"domain" : "global",
"message" : "Delegation denied for <user email>",
"reason" : "forbidden"
} ],
"message" : "Delegation denied for <user email>"
}
I am using OAuth 2.0 and Google Apps Domain-Wide delegation of authority to access the user data. The domain has granted data access rights to the application.
Seems like best thing to do is to just always have userId="me" in your requests. That tells the API to just use the authenticated user's mailbox--no need to rely on email addresses.
I had the same issue before, the solution is super tricky, you need to impersonate the person you need to access gmail content first, then use userId='me' to run the query. It works for me.
here is some sample code:
users = # coming from directory service
for user in users:
credentials = service_account.Credentials.from_service_account_file(
SERVICE_ACCOUNT_FILE, scopes=SCOPES)
####IMPORTANT######
credentials_delegated = credentials.with_subject(user['primaryEmail'])
gmail_service = build('gmail', 'v1', credentials=credentials_delegated)
results = gmail_service.users().labels().list(userId='me').execute()
labels = results.get('labels', [])
for label in labels:
print(label['name'])
Our users had migrated into a domain and their account had aliases attached to it. We needed to default the SendAs address to one of the imported aliases and want a way to automate it. The Gmail API looked like the solution, but our privileged user with roles to make changes to the accounts was not working - we kept seeing the "Delegation denied for " 403 error.
Here is a PHP example of how we were able to list their SendAs settings.
<?PHP
//
// Description:
// List the user's SendAs addresses.
//
// Documentation:
// https://developers.google.com/gmail/api/v1/reference/users/settings/sendAs
// https://developers.google.com/gmail/api/v1/reference/users/settings/sendAs/list
//
// Local Path:
// /path/to/api/vendor/google/apiclient-services/src/Google/Service/Gmail.php
// /path/to/api/vendor/google/apiclient-services/src/Google/Service/Gmail/Resource/UsersSettingsSendAs.php
//
// Version:
// Google_Client::LIBVER == 2.1.1
//
require_once $API_PATH . '/path/to/google-api-php-client/vendor/autoload.php';
date_default_timezone_set('America/Los_Angeles');
// this is the service account json file used to make api calls within our domain
$serviceAccount = '/path/to/service-account-with-domain-wide-delagation.json';
putenv('GOOGLE_APPLICATION_CREDENTIALS=' . $serviceAccount );
$userKey = 'someuser#my.domain';
// In the Admin Directory API, we may do things like create accounts with
// an account having roles to make changes. With the Gmail API, we cannot
// use those accounts to make changes. Instead, we impersonate
// the user to manage their account.
$impersonateUser = $userKey;
// these are the scope(s) used.
define('SCOPES', implode(' ', array( Google_Service_Gmail::GMAIL_SETTINGS_BASIC ) ) );
$client = new Google_Client();
$client->useApplicationDefaultCredentials(); // loads whats in that json service account file.
$client->setScopes(SCOPES); // adds the scopes
$client->setSubject($impersonateUser); // account authorized to perform operation
$gmailObj = new Google_Service_Gmail($client);
$res = $gmailObj->users_settings_sendAs->listUsersSettingsSendAs($userKey);
print_r($res);
?>
I wanted to access the emails of fresh email id/account but what happened was, the recently created folder with '.credentials' containing a JSON was associated with the previous email id/account which I tried earlier. The access token and other parameters present in JSON are not associated with new email id/account. So, in order make it run you just have to delete the '.credentails' folder and run the program again. Now, the program opens the browser and asks you to give permissions.
To delete the folder containing files in python
import shutil
shutil.rmtree("path of the folder to be deleted")
you may add this at the end of the program
Recently I started exploring Gmail API and I am following the same approach as Guo mentioned. However, it is going to take of time and too many calls when we the number of users or more. After domain wide delegation my expectation was admin id will be able to access the delegated inboxes, but seems like we need to create service for each user.
I'm currently working on the imap class by barbushin. It's the only php class over the internet I can find regardless to any encoding issue. Thanks to the coder.
I have a list of messages in a table. Each message sending a message id as GET (say $mid). When a link clicked, the page turned into a view page. It should open that message and display the relevant content right? But it is not. Every message has the same content (the 1st content). The code is designed for gmail but I use it for my client. And it's work.
This is a code:
require_once('../ImapMailbox.php');
define('EMAIL', 'my#domain.com');
define('PASSWORD', '*********');
define('ATTACHMENTS_DIR', dirname(__FILE__) . '/attachments');
$mailbox = new ImapMailbox('{imap.gmail.com:993/imap/ssl}INBOX', EMAIL, PASSWORD, ATTACHMENTS_DIR, 'utf-8');
$mails = array();
// Get some mail
$mailsIds = $mailbox->searchMailBox('ALL');
if(!$mailsIds) {
die('Mailbox is empty');
}
$mailId = reset($mailsIds);
$mail = $mailbox->getMail($mailId);
var_dump($mail);
var_dump($mail->getAttachments());
The original is here: https://github.com/barbushin/php-imap
Finally, I found my way home. According to the script there's a line says "mailId". Which is straight forward what is it about.
It was set to the first array by reset(). So the only thing I need to do is extract the message id from it ($mailId is an array of ids). So I simply add an array behind it.
$mailId=$mailsIds[$_GET[uid]];
While $_GET[uid] is a message id sent from a previous page.