I am new to gcm upstream messaging. I am trying to connect to the cloud connection servers via xmpp (using c# agsxmpp library). However, I am getting a not authorized error message from the server and the connection is closed immediately even though the same project number/api key works for http downstream push notifications. Any help is appreciated.
Here is the code.
var username = Configuration.PROJECT_NUMBER + "#" + Configuration.GCM_SERVER;
xmpp = new XmppClientConnection
{
UseSSL = true,
UseStartTLS = false,
Server = Configuration.GCM_SERVER,
ConnectServer = Configuration.GCM_SERVER,
Port = Configuration.GCM_PORT,
Username = username,
Password = Configuration.GCM_API_KEY,
AutoResolveConnectServer = true,
SocketConnectionType = SocketConnectionType.Direct,
AutoAgents = false,
KeepAlive = true,
AutoRoster = false,
AutoPresence = false,
UseCompression = false,
Show = ShowType.chat
};
xmpp.OnReadSocketData += Xmpp_OnReadSocketData;
xmpp.OnWriteSocketData += Xmpp_OnWriteSocketData;
xmpp.OnLogin += Xmpp_OnLogin;
xmpp.OnMessage += Xmpp_OnMessage;
xmpp.OnError += Xmpp_OnError;
xmpp.OnClose += Xmpp_OnClose;
xmpp.OnAuthError += Xmpp_OnAuthError;
xmpp.Open();
}
And here is the interaction with the ccs (captured from the OnReadSocketData and OnWriteSocketData events)
To CCS<<11:59:58 834
<stream:stream to='gcm.googleapis.com' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' xml:lang='en'>
From CSS>> 11:59:59 037
<stream:stream from="gcm.googleapis.com" id="AF8BBDE576QWEFF3543" version="1.0" xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client">
From CSS>> 11:59:59 101
<stream:features><mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><mechanism>X-OAUTH2</mechanism><mechanism>X-GOOGLE-TOKEN</mechanism><mechanism>PLAIN</mechanism></mechanisms></stream:features>
To CCS<<11:59:59 115
<auth xmlns="urn:ietf:params:xml:ns:xmpp-sasl" mechanism="PLAIN">ADIwNjAxOTEwOTA2Mlw0MGjkdf4y67fvbjjdgESnhaa2tFX3hIcm56NXhWZndJclpFUmlMbnBqNVFIdkk=</auth>
From CSS>> 11:59:59 312
<failure xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><not-authorized/></failure>ism>X-OAUTH2</mechanism><mechanism>X-GOOGLE-TOKEN</mechanism><mechanism>PLAIN</mechanism></mechanisms></stream:features>
From CSS>> 11:59:59 314
</stream:stream>urn:ietf:params:xml:ns:xmpp-sasl"><not-authorized/></failure>ism>X-OAUTH2</mechanism><mechanism>X-GOOGLE-TOKEN</mechanism><mechanism>PLAIN</mechanism></mechanisms></stream:features>
I changed the username from <Project_Number>#<GCM_Server_Address> to just <Project_Number> and it is working.
Related
Yesterday I was using the following code to get data out of my MS Dataverse through R. It was working fine.
require(httr)
require(rvest)
dataverse_api = oauth_endpoint(request = NULL,
authorize = "https://login.microsoftonline.com/REDACTED/oauth2/v2.0/authorize",
access = "https://login.microsoftonline.com/REDACTED/oauth2/v2.0/token",
base_url = "https://login.microsoftonline.com/common/oauth2/authorize?resourcehttps://org593dc393.crm4.dynamics.com")
API.Key = "REDACTED"
API.Secret = "REDACTED"
App = oauth_app("EPS Project Development", key = API.Key, secret = API.Secret)
API.token = oauth2.0_token(dataverse_api, App, scope = "https://org593dc393.crm4.dynamics.com/.default")
API.AuthKey = API.token$credentials$access_token
GET.Buildings = GET("https://org593dc393.crm4.dynamics.com/api/data/v9.2/crfd0_dartbuildingses", add_headers(Authorization = paste("Bearer", API.AuthKey, sep = " ")))
Today, trying to run the same lines of code with no modifications is giving me a 401 error. Based on some research on debugging 401 errors (none of them specific to MS Dataverse) I tried clearing my cache, clearing my cookies, flushing my DNS with ipconfig/flushdns and navigating directly to the endpoint and inspecting the request, which returned the following 200 response:
With all of these efforts, despite the fact that this code worked yesterday, I am still getting the following response in R:
I also generated a new token using Postman. When I run the GET command using that token, I get a status of 200.
API.AuthKey = "REDACTED TOKEN FROM POSTMAN"
GET.Buildings = GET("https://org593dc393.crm4.dynamics.com/api/data/v9.2/crfd0_dartbuildingses", add_headers(Authorization = paste("Bearer", API.AuthKey, sep = " ")))
GET.Buildings$status_code
[1] 200
Is it apparent to anyone in the R response to my initial attempt what I've done wrong? If not, how can I debug this?
It turned out the code was supplying the same Access Token each time. I just needed to add cache = FALSE so that I'm not using cached tokens. If it's helpful to anyone, the full code is now:
require(httr)
require(rvest)
dataverse_api = oauth_endpoint(request = NULL,
authorize = https://login.microsoftonline.com/REDACTED/oauth2/v2.0/authorize,
access = https://login.microsoftonline.com/REDACTED/oauth2/v2.0/token,
base_url = https://login.microsoftonline.com/common/oauth2/authorize?resourcehttps://org593dc393.crm4.dynamics.com)
API.Key = "REDACTED"
API.Secret = "REDACTED"
App = oauth_app("EPS Project Development", key = API.Key, secret = API.Secret)
API.token = oauth2.0_token(dataverse_api, App, scope = https://org593dc393.crm4.dynamics.com/user_impersonation, cache = FALSE)
API.AuthKey = API.token$credentials$access_token
GET.Buildings = GET(https://org593dc393.crm4.dynamics.com/api/data/v9.2/crfd0_dartbuildingses, add_headers(Authorization = paste("Bearer", API.AuthKey, sep = " ")))
string accountID = "*****";
string envolopeID = "****************";
apiClient = new ApiClient("https://demo.docusign.net/restapi");
apiClient.SetBasePath("https://account-d.docusign.com/restapi/v2.0/accounts/" + accountID + "/envelopes/" + envolopeID + "/documents/1" );
code = Request.QueryString["code"].ToString();
OAuth.OAuthToken oAuthToken = GenerateAccessToken(IntegratorKey, ClientSecret, code, "userID", "password");
apiClient.Configuration.DefaultHeader.Add("Authorization", "Bearer " + oAuthToken.access_token);
EnvelopesApi envelopesApi = new EnvelopesApi(apiClient);
Stream results1 = envelopesApi.GetDocument(accountID, envolopeID, "1");
I am trying to get signed completed document from DocuSign but unable to download it.
after getting response in result1 gives error as below
ReadTimeout = 'results1.ReadTimeout' threw an exception of type 'System.InvalidOperationException'
WriteTimeout = 'results1.WriteTimeout' threw an exception of type 'System.InvalidOperationException'
Is my code/logic is correct? How to download signed completed document from DocuSign? Please help to download document.
I am using ASP.Net web forms and .NET framework 4.5.2
DocuSign.eSign.dll 5.2.0
DocuSign.Integration.Client.dll 1.7.2
Thanking you...
What does GenerateAccessToken() do? the "password" is making me think this thing is not the correct way to obtain OAuth 2.0 token. If you generated the token correctly then try this for the first few lines:
For now, your code in demo/developer account, you don't need to set baseURL just to get you working. The URL you had there is wrong.
var apiClient = new ApiClient(basePath);
apiClient.Configuration.DefaultHeader.Add("Authorization", "Bearer " + accessToken);
var envelopesApi = new EnvelopesApi(apiClient);
Find more about downloading completed documents.
I am trying to connect (dotnet client) to RabbitMQ. I enabled the Peer verification option from the RabbitMQ config file.
_factory = new ConnectionFactory
{
HostName = Endpoint,
UserName = Username,
Password = Password,
Port = 5671,
VirtualHost = "/",
AutomaticRecoveryEnabled = true
};
sslOption = new SslOption
{
Version = SslProtocols.Tls12,
Enabled = true,
AcceptablePolicyErrors = System.Net.Security.SslPolicyErrors.RemoteCertificateChainErrors
| System.Net.Security.SslPolicyErrors.RemoteCertificateNameMismatch,
ServerName = "", // ?
Certs = X509CertCollection
}
Below are my client certification details which I am passing through "X509CertCollection".
CertSubject: CN=myhostname, O=MyOrganizationName, C=US // myhostname is the name of my client host.
So, if I pass "myhostname" value into sslOption.ServerName, it works. If I pass some garbage value, it still works.
As per documentation of RabbitMQ, these two value should be match i.e. certCN value and serverName. What will be the value of sslOption.ServerName here and why?
My Bad. I found the reason. Posting as it might help someone.
Reason: As I set a policy "System.Net.Security.SslPolicyErrors.RemoteCertificateNameMismatch".
I am trying to send multi-part SMS in Arabic (UTF-8) format using Clickatell Operator, I am unable to, 1 part Arabic SMS works fine, multi-part English SMSs also work fine, just the multi-part Arabic SMSs don't.
These are my configurations:
group = smsc
smsc-id = clickatell
smsc = http
system-id = ******
system-type = clickatell
smsc-username = ******
smsc-password = ******
send-url = "http://api.clickatell.com/http/sendmsg"
port = 13015
allowed-smsc-id = clickatell
connect-allow-ip = "127.0.0.1;192.168.100.*;196.30.96.134"
log-file = "/var/log/kannel/clickatell/clickatell.log"
log-level = 0
AND, my sendsms configurations:
group = sendsms-user
username = ***
password = ***
concatenation = true
max-messages = 7
Any help or thoughts would be nice, thanks.
I have a function that uses CDO to send emails with request to have a delivery receipt when the mail reacehes the recepient.
I use the following code:
CDO.Message msg = new CDO.Message();
CDO.Configuration conf = new CDO.Configuration();
conf.Fields["http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"].Value = 1;
conf.Fields["http://schemas.microsoft.com/cdo/configuration/smtpserver"].Value = txtHost.Text;
conf.Fields["http://schemas.microsoft.com/cdo/configuration/smtpserverport"].Value = 25;
conf.Fields["http://schemas.microsoft.com/cdo/configuration/sendpassword"].Value = txtPass.Text;
conf.Fields["http://schemas.microsoft.com/cdo/configuration/sendusername"].Value = txtUser.Text;
conf.Fields.Update();
msg.Configuration = conf;
msg.To = txtTo.Text;
msg.From = txtFrom.Text;
msg.Subject = txtSubject.Text+" " + DateTime.Now;
msg.HTMLBody = txtBody.Text;
msg.BodyPart.Charset = "utf-8";
msg.DSNOptions = CdoDSNOptions.cdoDSNSuccessFailOrDelay;
msg.Fields.Update();
msg.Send();
Now this works fine on my local machine with my web server, but when used in the production server with another mail server the delivery receipts were not received.
I believe there must be a difference between my mail server and the production mail server but I don't know what it can be exactly.
So please if anybody has faced such a problem before, tell me what to do.
It works on your local machine almost by accident because you're delivering it to yourself. To work out in the world you have to explicitly tell CDO not to deliver to the local smtp for relaying by specifying sendUsingPort
conf.Fields["ttp://schemas.microsoft.com/cdo/configuration/sendusing"].Value = 2