I'm trying to invoke one AWS Lambda function from my Android application.
If I understand correctly, I have to start with something like this:
BasicAWSCredentials creds = new BasicAWSCredentials(keyId, secret);
AWSLambdaClientBuilder builder = AWSLambdaClientBuilder.standard()
.withCredentials(new AWSStaticCredentialsProvider(creds))
.withRegion(regionName);
AWSLambda lambdaClient = builder.build();
and then the rest of the code with InvokeRequest etc.
Problem is in the above code, after it app crashes. I can't find the correct set of libs to make this work in Android.
If I use
implementation 'com.amazonaws:aws-java-sdk-lambda:1.11.782'
then it compiles fine and executes up to the "builder.build()" and then crashes and if I use
implementation 'com.amazonaws:aws-android-sdk-lambda:2.16.12'
(which is supposed to be used for Android???) Then "import com.amazonaws.services.lambda.AWSLambdaClientBuilder;" is red cause there's no such thing in the lib..
I get that AWSLambdaClient is deprecated and AWSLambda should be used, then what about AWSLambdaClientBuilder? What should I use?
Basically, if everything above is wrong, how do I get to call AWS Lambda function (by the way, this is without using API Gateway) from an Android app? What libs (with versions) would work for it?
I tried to follow https://docs.aws.amazon.com/lambda/latest/dg/with-android-example.html tutorial, but they also have deprecated stuff, plus it wants to involve Cognito and I was under the impression that I could call a function directly with a key and secret of a user with specific policy..
A different approach, but you can use the API gateway or application load balancer and call the configured endpoint from the android application.
Benefit with this, you will not need to configure the application to have the client id, and client secret set up, and even if restart, it would be simple api gateway call.
Lambda can work with both API Gateway as well as Application Load Balancer, and it is pretty easy to configure. Refer this page for details on ALB with Lambda.
Related
I am using the Checkout dependency from Razorpay. I pass the required data to the checkout object using JSONObject and proceed to payment. On successful payment, a method is supposed to be executed and an order is placed to the server once the user, resumes the application.
But it seems UPI payments block this as they do not redirect back to the application and the method is never executed and the user has already paid for the order.
Razorpay support suggested using UPI Intent flow as a possible solution for this.
And according to the documentation on RazorPay's website UPI Intent Flow Integration, a library needs to be added and a RazoryPay class is supposed to be used.
As mentioned before I am using Checkout dependency and using this new library throws a Duplicate Build Config error for RazorPay lib and Checkout dependency.
Removing Checkout dependency and using the library fixes it but now the Payment process is supposed to be shifted to a WebView and the required data needs to be passed through JS on the webview. And am not confident in using a webview as I lack knowledge in using JS.
I would like to know a possible alternative to using a webview or a way to redirect back to the application and execute the method.
Note
I am aware of callback_url object for Checkout method but my order is never created before payment. Hence using a callback url doesn't work well
I've set up a small android and firebase app... Authentification works like a charm, and in the firebase console, I can see my user, logged in with the Google account.
Now I am trying to experiment a little with the Text to Speech api, and in doing so, I followed this tutorial:
https://github.com/GoogleCloudPlatform/java-docs-samples/tree/master/texttospeech/cloud-client
I managed to make the small java app work, by setting the GOOGLE_APPLICATION_CREDENTIALS Environment variable (I followed this tutorial for this step: https://cloud.google.com/docs/authentication/getting-started), but I am not sure what I need to do to make that code work in the Android app where the users are authentificated..
The Error that I get when trying to make a call to the TextToSpeech API is:
The Application Default Credentials are not available. They are
available if running in Google Compute Engine. Otherwise, the
environment variable GOOGLE_APPLICATION_CREDENTIALS must be defined
pointing to a file defining the credentials. See
https://developers.google.com/accounts/docs/application-default-credentials
for more information.
The error mentioned comes from the line:
TextToSpeechClient textToSpeechClient = TextToSpeechClient.create();
This error appears because of the fact that on the android emulator I don't have access to the credentials that are set as environment variable in my OS..So I have to provide the credentials in another way.
In the case of other Google APIs, like Storage, I found out that this can be done like this:
// You can specify a credential file by providing a path to GoogleCredentials.
// Otherwise credentials are read from the GOOGLE_APPLICATION_CREDENTIALS environment variable.
GoogleCredentials credentials = GoogleCredentials.fromStream(new FileInputStream(jsonPath))
.createScoped(Lists.newArrayList("https://www.googleapis.com/auth/cloud-platform"));
Storage storage = StorageOptions.newBuilder().setCredentials(credentials).build().getService();
I managed to create the GoogleCredentials object with the contents of the json file, however the TextToSpeech client doesn't seem to provide a functionality similar to this:
StorageOptions.newBuilder().setCredentials(credentials).build()
So my question is....is there a way to provide the Credentials object to the TextToSpeech client?
Thanks
Currently, there is not a way to provide credentials to the TTS Client from this page.
Due to Security / Auth reasons, I believe the best suggested approach is to use Firebase Functions.
Get the Text
Call Firebase Functions
Have Firebase Functions call the TTS API
Return the results.
This way, no keys are leaked inside the application and you can use Firebase Auth.
Let me know if that helps!
Update:
Option 2: iOS Tutorial (should be adaptable to Android)
Get the Text
Call Firebase Functions
Have Firebase Functions return an OAuth2 Token
Use the token directly with the API
As we know, there have been changes in access to the twitter API referring to callbacks URLs.
So far, I have been using the identification callback with firebase, as I indicated here:
This has been working perfectly so far.
I read in the documentation that now you have to indicate the callback, according to android or iOS in the following way:
twitterkit- : // if using Twitter Kit for iOS or
twittersdk: // if using Twitter Kit for Android.
My application is only developed for android.
I have tried all the possible variants, but I always get the following error:
The client application failed validation: Not a valid callback URL format.
The tested options have been:
twittersdk://pfa89MGYola62VIln ........ (MY_CONSUMER_KEY)
twittersdk://MY_APP-android.firebaseapp.com/__/auth/handler
twittersdk://https://MY_APP-android.firebaseapp.com/__/auth/handler
I have activated and deactivated the check "enable callback locking" ...
I've tried everything, I'm a little desperate
For another test, I tried to register the URL callback as if it were the iOS platform
twitterkit-MY_CONSUMER_KEY://
and it was accepted on the first attempt.
I do not mind losing the relationship with firebase, the truth is that I was not using it, but I have a serious problem if I can not connect with twitter again.
I appreciate any help.
I found the solution, I put it here in case it can be of help to someone.
The truth is that it is not well specified in the documentation, you have to take two steps.
First: activate the "enable callback locking" checkbox
Second: indicate the android sdk for twitter, WITHOUT CONSUMER KEY, unlike iOS users.
It would be like this:
I hope it helps
I have a Worklight 6.2 app. I am modifying the android java code to subscribe to a notification sent via Bluemix. After the user logs in, I would like to register the device using the userid that gets created. Is there an API call that I can use within the android code that is the equivalent to WL.Client.getUserName, or should I be calling the java code from my javascript and passing the userName to the java code? Thanks for any suggestions.
JT
There is no Java equivalent to this. This is a Worklight API.
What you can do is use the new WL.App.sendActionToNative method in Worklight 6.2 for to send a value to your native code and from there do what you need with it.
WL.App.sendActionToNative(“doSomething”, { customData: 12345} );
Where customdData is the WL.Client.getUserName.
On the native side you then need to use WLActionReciever (see What's New).
You could also opt to implement a basic Cordova plug-in that will move data from the web to native view.
The tutorial in the Getting Started page is doing exactly that.
I am creating a android application for eCommerce website.
Here at server side, i am using Shopify's eCommerce software.
So how could i call web service generated through Shopify's eCommerce software.
I have make research on it..
I found one link also link, but that demo is not running.
I need one simple demo where how can i use shopify api in android application
That Demo is working, I checked it today only. You can make a webview and use the Java/Android Library to make the call.
Use this part to make your call (for more details check demo code or api page):
JsonDirectoryCredentialsStore store = new JsonDirectoryCredentialsStore(getFilesDir());
Credential emptyCredential = makeEmptyCredential(shopname);
store.saveCredential(emptyCredential);
APIAuthorization auth = new APIAuthorization(emptyCredential);
URI authRequest = auth.generateAuthRequest();
Pass this authRequest to a webview and set a webviewclient to handle redirections by shopify.
You can then set up a callback to your localhost in the dev store you created and connect to that with the emulator loopback interface 10.0.2.2 from the app to test. At least that's the most convenient way I found.