Shows Permission Denial error for titanium appcelerator - appcelerator-mobile

I used the below code
var findus = Ti.Contacts.getPeopleWithName('john');
and the error i got is
uncaught error: permission denial : reading com.android.providers.contacts.contactsprovider2 uri content://com.android.contacts/data from pid=277, uid=10045 requires android.permission. READ_CONTACTS
But i have placed the below lines in tiapp.xml
<android xmlns:android="http://schemas.android.com/apk/res/android"> <manifest>
<uses- permission android:name="com.get.permission.READ_CONTACTS"
android:protectionLevel="signature"/> </manifest> </android>
Android version : 2.2 sdk : 1.8.2 os
please help on this issue.........

It seems that you've not requested an authorization.
Please request an authorization before accessing contacts. The following example is from Titanium docs (http://docs.appcelerator.com/titanium/latest/#!/api/Titanium.Contacts):
var performAddressBookFunction = function(){
var findus = Ti.Contacts.getPeopleWithName('john');
};
var addressBookDisallowed = function(){alert('Sorry');};
if (Ti.Contacts.contactsAuthorization == Ti.Contacts.AUTHORIZATION_AUTHORIZED){
performAddressBookFunction();
} else if (Ti.Contacts.contactsAuthorization == Ti.Contacts.AUTHORIZATION_UNKNOWN){
Ti.Contacts.requestAuthorization(function(e){
if (e.success) {
performAddressBookFunction();
} else {
addressBookDisallowed();
}
});
} else {
addressBookDisallowed();
}

The name of the permission is "android.permission.READ_CONTACTS" rather than "com.get.permission.READ_CONTACTS".
Try the following in your tiapp.xml:
<android xmlns:android="http://schemas.android.com/apk/res/android">
<manifest>
<uses-permission android:name="android.permission.READ_CONTACTS" android:protectionLevel="signature"/>
</manifest>
</android>

Related

Google.cloud.speech.v1.RecognizeRequest can't recognize bucket?

I follow community google cloud platform to connect to twilio to capture voice call and save to bucket. However, it can't translate the voice, due to the following error message. Does anyone know why
google.cloud.speech.v1.RecognizeRequest can't recognize bucket?
(url: https://cloud.google.com/community/tutorials/cloud-functions-twilio-voice-record)
"Error: .google.cloud.speech.v1.RecognizeRequest#bucket is not a field: undefined
at Error (native)
at MessagePrototype.set (/user_code/node_modules/#google-cloud/speech/node_modules/protobufjs/dist/protobuf.js:2490:35)
at MessagePrototype.set (/user_code/node_modules/#google-cloud/speech/node_modules/protobufjs/dist/protobuf.js:2483:38)
at Message (/user_code/node_modules/#google-cloud/speech/node_modules/protobufjs/dist/protobuf.js:2411:34)
at serialize (/user_code/node_modules/#google-cloud/speech/node_modules/grpc/src/node/src/protobuf_js_5_common.js:81:23)
at ServiceClient.Client.makeUnaryRequest (/user_code/node_modules/#google-cloud/speech/node_modules/grpc/src/node/src/client.js:530:17)
at apply (/user_code/node_modules/#google-cloud/speech/node_modules/lodash/lodash.js:499:17)
at ServiceClient.wrapper [as recognize] (/user_code/node_modules/#google-cloud/speech/node_modules/lodash/lodash.js:5356:16)
at /user_code/node_modules/#google-cloud/speech/src/v1/speech_client.js:111:41
at timeoutFunc (/user_code/node_modules/#google-cloud/speech/node_modules/google-gax/lib/api_callable.js:177:12)"
timestamp: "2017-08-07T17:27:02.601Z"
I solved this with the following code:
var config = {
sampleRateHertz: 8000,
encoding: 'LINEAR16',
languageCode: 'en-US'
};
var uri = `gs://${object.bucket}/${object.name}`;
var audio = {
uri : uri
};
var request = {
config: config,
audio: audio
};
// Transcribe the audio file
return speech.recognize(request)
By the way: I also had to comment out the 'annotate' function below to get it to work

How to call processing page via web service

I have a processing page and I want to run function process all via web service (add web reference into my C# window form app). My code below:
var context = new ModuleABCService.Screen() // limk web services: http://localhost:8686/soap/DMSBL009.asmx
{
CookieContainer = new CookieContainer(),
AllowAutoRedirect = true,
EnableDecompression = true,
Timeout = 60000
};
var loginResult = context.Login(string.Format("{0}#{1}", val.UserName, company), val.Password);
if (loginResult.Code != ErrorCode.OK)
{
throw new Exception(string.Format("Can not login {0}", company));
}
Content content = context.GetSchema();
context.Clear();
context.Submit(
new Command[]
{
content.Actions.ProcessAll
}
);
And I got an exception message:
System.Web.Services.Protocols.SoapExceptio:n Server was unable to process request. ---> PX.Data.PXUndefinedCompanyException: Unable determine proper company id for the request. at PX.Data.PXDatabaseProviderBase.getCompanyID(String tableName, companySetting& setting) in c:\Builders\4_10-2014_4_28-21_21_17-Full\Scripts\BuildTemp\NetTools\PX.Data\Database\Common\DbProviderBaseCompanies.cs:line 471...
Have you ever got this error before? Could you please give me any suggestion? Thank you so much!
Ok, I found out, because Acumatica's license

Silverlight not finding clientaccesspolicy.xml in Owin self hosted Web Api

I am aware of the hundreds of similar questions about Silverlight and the clientaccesspolicy.xml but I am losing my head here. I've gone through almost all the posts on Stackoverflow, tried most of the suggestions and I'm still stuck.
I have a SL client calling a method in an Owin self-hosted web api. I've simplified my api service to this example, so there is no unnecessary complexity involved. My api is running on port 9000 for this example.
The problem is that I get a 404 error when calling the method in the api. Using Fiddler I can tell that it's not finding the clientaccesspolicy.xml. I've copied the xml file (and crossdomain.xml) to all locations I can think of, and to that of what other posts have suggested.
Can anyone point out my error or help me in the right direction? Here are some snippets:
clientaccesspolicy.xml:
<?xml version="1.0" encoding="utf-8"?>
<access-policy>
<cross-domain-access>
<policy>
<allow-from http-request-headers="SOAPAction">
<domain uri="http://*"/>
<domain uri="https://*"/>
</allow-from>
<grant-to>
<socket-resource port="9000" protocol="tcp" />
<resource path="/" include-subpaths="true"/>
</grant-to>
</policy>
</cross-domain-access>
</access-policy>
Program.cs
static void Main(string[] args)
{
string baseAddress = "http://localhost:9000/";
Console.WriteLine("Connected..");
var server = WebApp.Start<Startup>(url: baseAddress);
Console.ReadLine();
Console.WriteLine("Disconnecting..");
server.Dispose();
}
Service Agent in SL:
public async Task TestApi()
{
try
{
HttpClient client = new HttpClient();
var response = await client.GetAsync("http://localhost:9000/api/test");
var result = await response.Content.ReadAsStringAsync();
... bla bla bla
}
catch (Exception e)
{
throw new Exception(e.Message);
}
}
When using self hosting you will have to serve the policy file yourself by listening for the request for the policy and passing back the policy file.
See: Cross domain policy file over net.tcp for WCF servicehost and Silverlight 5

Error when accessing ESB Proxy with Jaggery WSStub

I created a web service and was able to send requests to it from a serverside Jaggery.js script with no problem. Then I created a WSDL Proxy Service inside WSO2 ESB and tested it using the "Try it!" feature.
After I redirected my serverside script from the original web service to its proxy inside ESB, I got the error in System Logs:
The endpoint reference (EPR) for the Operation not found is /services/BpmAdderProcessProxy.BpmAdderProcessProxyHttpSoap11Endpoint and the WSA Action = urn:anonOutInOpResponse. If this EPR was previously reachable, please contact the server administrator.
To see in detail what was happening I activated the "SOAP Message Tracer" of the ESB. Suddenly my serverside script could access the webservice via my ESB proxy. Then I deactivated the "SOAP Message Tracer" and the error message was back again. Is my serverside script correct? Or does the debugging tool modify behavior of debugged code?
I'm a JavaScript developer. Actually Jaggery and UES are targeted at people like me. I'm not supposed to look inside Java code, am I? Is there a forum where JavaScript developers discuss WSO2 UES and Jaggery?
My serverside code is as follows:
<%
var x = request.getParameter("x");
var y = request.getParameter("y");
//var sum = parseInt(x) + parseInt(y);
var sum = add(parseInt(x), parseInt(y));
response.content = {
success: true,
data: {
result: sum
}
};
function add(x, y) {
var ws = require('ws');
var stub = new ws.WSStub("http://02-128:8280/services/BpmAdderProcessProxy?wsdl");
var process = stub.services["BpmAdderProcessProxy"].operations["process"];
var payloadTemplate = process.payloadXML();
var payload = replaceQuestionMarks(payloadTemplate, arguments);
var resultXml = process.request(payload);
var resultValue = resultXml.children().text();
return parseInt(resultValue);
}
function replaceQuestionMarks(template, values) {
var i = 0;
return template.replace(
/\?/g,
function() {
return values[i++];
}
);
}
%>
In ESB v4.8.1, pass-through transport is enabled by default and it does not support SOAP body based dispatching (it does not build the message so it can't acces the body's first element to find the operation)
You can append the operation name to the endpoint url : http://host:8280/services/BpmAdderProcessProxy/OperationName
You can add this parameter in your proxy conf (BpmAdderProcessProxy) in WSO2 ESB : <parameter name="disableOperationValidation" locked="false">true</parameter>
You can edit wso2esb/repository/conf/axis2/axis2.xml and replace <handler class="org.apache.axis2.dispatchers.SOAPMessageBodyBasedDispatcher" name="SOAPMessageBodyBasedDispatcher"/>
with
<handler class="org.apache.synapse.core.axis2.SynapseSOAPMessageBodyBasedDispatcher" name="SOAPMessageBodyBasedDispatcher"/>

Facebook OAuthException: (#1)

I have a few applications which upload image to user profile. A few hours ago all applications were working fine but now when uploading is requested, it gives this error
Fatal error: Uncaught OAuthException: (#1) An unknown error occurred thrown in applications/fb-sdk/facebook.php on line 543
I'm using the following code to publish image.
$FILE = "images/$image";
$args = array('message' => 'My msg ');
$args['image'] = '#' . realpath($FILE);
$data = $facebook->api('/'.$uid.'/photos', 'post', $args);
Is it because of some policy change or some new feature?
I have all the permissions like upload is set to true and application takes permission to upload file.
P.s: when the application is used 2nd time, it works fine.
You need to verify if the user is logged in AND has the permissions to post on wall. We're going to do that with a TRY/CATCH with a call to the user.
$userId = $facebook -> getUser();
if ($userId) {
try {
// Proceed knowing you have a logged in user who's authenticated.
$user_profile = $facebook->api('/me');
} catch (FacebookApiException $e) {
$userId = NULL;
error_log($e);
}
}
$app_permissions = array(
'scope' => 'publish_stream'
);
$logoutUrl = $facebook->getLogoutUrl();
$loginUrl = $facebook->getLoginUrl($app_permissions);
If the user is not logged in OR has authorized the app, you'll need to redirect him via header redirect or with a link.
if ($userId){
//Then you can call the facebook api
$data = $facebook->api('/'.$uid.'/photos', 'post', $args);
//... ...
}
That's the easiest way i've found.
EDIT : This question on stack has helped me : Facebook PHP SDK Upload Photos
No, the error is caused by the system cannot get the image file. Facebook will not allow the empty image field appear in the api. So it return Fatal error: Uncaught OAuthException: (#1) --- although it does not relate to the OAuth and OAuthException.