amplify init fails constantly - android

I don't know whats really wrong with my amplify. I run amplify init and get this error message. I have downloaded my amplify cli using npm and have successfully run 'amplify configure'.
init failed
InvalidSignatureException: The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details.
The Canonical String for this request should have been
'POST
/apps
host:amplify.ap-south-1.amazonaws.com
x-amz-content-sha256:79ec4b759220a7b1d454721bb2c7e1350dccbd691853e5ed1b3c92bec21dbc29
x-amz-date:20210121T154050Z
host;x-amz-content-sha256;x-amz-date
79ec4b759220a7b1d454721bb2c7e1350dccbd691853e5ed1b3c92bec21dbc29'
The String-to-Sign should have been
'AWS4-HMAC-SHA256
20210121T154050Z
20210121/ap-south-1/amplify/aws4_request
b150344845c2c575fd957d63172173a367f2bacf0e817764a02e5b20d03c3811'

Okay, so I finally found out what was bugging me for last three days. A whitespace ( ).
Yes!
I had my folder inside the user with a whitespace in it, as in "First Last". Instead what I should have done is changed my folder name inside my C:\Users\First Last to C:\Users\FirstLast before starting, and then try to install my amplify CLI using the command curl -sL https://aws-amplify.github.io/amplify-cli/install-win -o install.cmd && install.cmd and proceed as mentioned in the documentation here.
To change the name of the User folder in windows 10, I watched this great YT! video

On Mac:
I was also getting the same error while using the aws amplify CLI tool in my nodejs project.
Like #miraquee noted above about the issue being a white space. I suspected that I also had the same issue. What I did to start clean was:
Delete the local .aws folder in my home folder on mac to start clean
rm -rf ~/.aws/
Ran amplify init again. This time when reaching the step where it asks you to create an IAM user, which subsequently takes opens your web browser to finish the creation of the new IAM user, I was very careful about copying in the Access Key Id and Secret Access Key
This time when I went through the flow in the CLI it worked.
If you want to see a video of these steps, checkout this YouTube video built by one of the engineers on the AWS amplify team
Youtube video link: https://www.youtube.com/watch?v=fWbM5DLh25U

Related

Unable to upload APKs to App Center to perform Espresso UI testing

I'll try being as detailed as I possibly can. Please excuse any formatting or language issues.
What I'm trying to do?
I'm trying to make an app to upload APKs to Appcenter to execute UI test cases on whatever devices a user provided. When finished, my app will show the results of the UI tests executed.
How am I doing it?
App center has provided a lot of APIs which may be viewed here. Executing a UI test is a 4 step process.
Create a new test run. This is working
Create hashses of files to be uploaded. This is working
Upload the actual files. I keep getting a 400 bad request OR "payload is too big" error. My APK file is only 1 MB & the upload works through Appcenter CLI.
Execute the test run created. This API is not working. Probably due to failure of 3rd step.
What do I need help with?
Step 3. above is not working for me. I keep getting the following error when I try to upload the APK file through curl/postman.
Curl command :
curl -i -F "data=#app-debug-androidTest.apk" -H "X-API-Token:API_TOKEN_HERE" -H "Content-Type:application/json" -X POST https://api.appcenter.ms/v0.1/apps/{ORG_NAME}/{APP_NAME}/test_runs/{TEST_RUN_ID_CREATED_IN_STEP_1}/files
Error received :
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Error</title>
</head>
<body>
<pre>Payload Too Large</pre>
</body>
</html>
The irony is, when the exact same API is executed by the Appcenter CLI, it works. If UI tests are executed as part of the build step, App center uses the exact same procedure & set of APIs to upload the APK. Please view the complete log here. For formatting purposes, I did not add in inline.
What am I doing wrong?
Your curl command in step 3 is trying to upload the binary file as multipart form data (in a param data that doesn't exist in the API spec). The /files endpoint expects no file upload, but is preparing the upload internally and then returns the upload URL to you. See here in the App Center CLI's code:
const directUrl = await this.getDirectUploadUrl(this._client, testRunId, file);
await this.makeDirectUpload(directUrl, file);
Remove -F "data=#app-debug-androidTest.apk" from your curl command, then check the response for the upload URL for this test run.
After a day and half, possibly two I was able to resolve this issue. I've posted an elaborate document here & below is the shorter version.
Once you've created a new test run, you need to upload your file hashes for the APKs generated from the gradle command $ ./gradlew clean assembleDebug assembleAndroidTest. The URL is mentioned in the location key in the response of /hashes/batch API. The body of the API will be similar to :
[{
"file_type":"app-file",
"checksum":"df798b4d07597db804546b8ca723780992811111", //Calculate your file's SHA-1 by using shasum util
"relative_path":"app-debug.apk"
}]
Now we upload the file on the URL received in response to the /hashes/batch API with the following body params in form-data format.
relative_path //The name of the file is adequate
file //The actual file
file_type //app-file for build APK and test-file for APK containing espresso tests
If the files upload properly, you may execute the test run by /start API end point.

Cant push into github from android studio

I can add my projects to one github account but with another account i can't. I have followed this website for GitHub and worked fine: https://www.londonappdeveloper.com/how-to-use-git-hub-with-android-studio/#comment-32683
Steps are: 1. create a new git repo. 2. from android studio- VCS> Import into version control> create git repo. 3. In windows root directory of project open bash command and type > git remote add origin https://github.com/xxx/myProject.git 4. then back to android studio and a)project>Git>add b)project>Git>Commit c) project>Git>repository>push
these steps worked fine and I get a successful message using one github account. But with another account i cant do it, i get the erro:
Failed with error: fatal: unable to access 'https://github.com/Rashedul/myProject.git/': The requested URL returned error: 403
Why is this happening and how to solve it?
First you should set username and password to access the URL and to login , set Authentication first.
git remote set-url origin https://yourusername#github.com/user/repo.git
Then you'll be asked for a password when trying to git push
This is on the http authentication format. You could set a password also:
https://youruser:password#github.com/user/repo.git
You should be aware that if you do this, your github password will be stored in plaintext in your .git directory, which is obviously undesirable.

Android-Studio git over ssh

I got a git-server on my Raspberry Pi with gitweb as webinterface.
Its working so far.
Now I want to connect via Android Studio with the built-in ssh to it.
My project dir is :
/home/git/straff.git
I'll connect with this command from Android Studio:
:ssh:git#192.168.178.21:/straff
Android Studio is giving me this when I test the connection:
Cannot access /straff/CVSROOT
I am using password auth for it. I can access from command line tools to my repo...
Why Android Studio cant?
I can access from command line tools to my repo...
Why Android Studio cant?
Your error is you are trying to access 192.168.178.21:/straff which is /straff on that machine. Either provide the full path like below or use this one
:ssh:git#192.168.178.21:straff
Old post:
You can try to specify the full path to Android Studio:
:ssh:git#192.168.178.21:/home/git/straff
I am using password auth for it.
That means the ssh connection doesn't use a private/public (~/.ssh/id_rsa(.pub)) key.
A good tutorial to follow with Android Studio is the one titled "How to push to a remote Git repository over SSH with private/public key authentication using Android Studio".
Hmm, should the URL be like:
ssh://git#192.168.178.21/straff
I had problems with setting ssh key. I solved it by creating id_rsa -titled file under .ssh-directory (under user home-dir) and putting my RSA-stuff into it.
If you already have the remote git repository, which you want to check out, and you have a private key, then the instructions on https://www.londonappdeveloper.com/how-to-push-to-a-remote-git-repository-over-ssh-with-privatepublic-key-authentication-using-android-studio/ might help to some extent, but they are for older version of Android Studio and they are too complicated.
What you need to do (especially when you start from scratch) is:
Ensure that your key is an OpenSSH key, and that it's a private key (not a public key). This is where the above mentioned instructions are misleading - they point to the key in supposedly Putty format (the .ppk file), and this doesn't work. If you have a Putty key, use Putty's puttygen.exe tool to export the private key in OpenSSH format.
Create the config file as described in those instructions. I.e.
create the text file named config in .ssh subdirectory of your user directory. In my case the path would be C:\Users\Eugene.ssh\config.
Put the following to this file:
Host my-host.com
HostName my-host.com
Port 22
IdentityFile C:\Users\Eugene.ssh\my-private-key-for-my-host.openssh
(the original instructions include indentation of lines 2-4, but I couldn't add any indentation here).
Use Checkout Project From Version Control menu item in Android Studio's welcome screen to initiate GIT checkout.
Use the following settings during checkout (curly brackets contain the values which you replace with yours):
Git Repository URL: {projectalias}#{my-host.com}:base/{projectname}
Parent directory: eg. "z:\Projects" The path which must exist, and in which the new project is created
Project directory: eg. "myproject". The directory with this name will be created in Parent directory, so the files will be checked out to Parent_directory\Project_directory, eg. "z:\Projects\myproject".

android build release apk on jenkins, without storing my password in plain text

I need to be able to build the release version of my apk, using a Jenkins job.
From reading the following SO question
How to create a release signed apk file using Gradle?
I understand I can do it in one of two ways. Either get the user to enter the password at cmd prompt, or store my password details in a plain text file that doesn't get committed to git, and lives on my local machine.
Neither of these will work when running the build job on jenkins though. 1) I can't gain user input because this may be running in the middle of the night (I don't even know how to get user input from the cmd line even if the user was at their machine) 2) Anyone who can gain access to that build box, would be able to cat the contents of that file either via the cmd line or from another build.gradle job running on that jenkins server.
Does anyone know of anyway I can keep my password hidden but so that the Jenkins job can access it?
Thanks
You can use Mask Password Plugin, which does just that. Or the same functionality is included in EnvInject plugin, and sooner or later all Jenkins projects get a need for EnvInject plugin (that does many other things), so might as well start using it now.
To securely use a password from within a build/post-build step
Install EnvInject plugin.
Under Jenkins Global Configuration, find Global Passwords section.
Add a name (this will be the environment variable name) and password (will be starred **** ).
Under Job Configuration, find Build Environment section.
Checkmark Inject passwords to the build as environment variables.
Then checkmark Global passwords.
In any build step, you can now use $name (as defined earlier) to refer to a password as you would if you were typing it in plain text.
The password variable is injected only at job execution time (typing $name on command line of the server by itself will not produce anything, and like all Jenkins variables, it is not persistent).
The job console log will show **** instead of password, if it appears.
You could configure passwords per job, rather than globally, so that other jobs can't use it.
The only security concern is that if someone has administrative permissions to configure your job, they can write echo $name > secretpassword.txt into a build step, and then review the file in the workspace. But you should be careful who you assign administrative rights to.
You should take a look for this plugin
https://wiki.jenkins-ci.org/display/JENKINS/Mask+Passwords+Plugin
If your Jenkins instance happens to be running on EC2, and you don't want to permanently store secrets in the file system, you can put the store and key passwords into Systems Manager Parameter Store, then query them at build time. In addition, you can put the keystore itself into external storage, such as S3, and only keep it locally for the duration of the build.
Here is a sample build script (assume that the secret parameters are named android-keystore-pass and android-signature-key-pass):
set -o errexit
set -o pipefail
keystore_file=keystore.properties
keystore=wise.jks
aws s3 cp s3://path-to-android/$keystore .
chmod go-rwx $keystore
touch $keystore_file
chmod go-rwx $keystore_file
cat > $keystore_file << EOF
storePassword=`aws ssm get-parameters --names android-keystore-pass --with-decryption | cut -f4`
keyPassword=`aws ssm get-parameters --names android-signature-key-pass --with-decryption | cut -f4`
keyAlias=android
storeFile=$WORKSPACE/$keystore
EOF
An example of the Gradle build scripts can be found in this answer. You can commit a dummy keystore.properties to source control so that (non-release) builds work on dev machines.
There are also open-source secret distribution tools that are platform-independent, e.g. Vault, but I haven't tried any of them.

phonegap facebook connect integration issue

I am trying to integrate my phonegap application with facebook through facebook connect plugin. I followed the instructions here since git wasn't working for me but I think I would end up with the exact same setup either way.
When I run the following code after doing FB.init() using my app ID, I get an alert saying "Cordova Facebook Connect Plugin failed on auth.status"
console.log('Debug 1');
var params = {
method: 'feed',
name: 'Facebook Dialogs',
link: 'https://developers.facebook.com/docs/reference/dialogs/',
picture: 'http://fbrell.com/f8.jpg',
caption: 'Reference Documentation',
description: 'Dialogs provide a simple, consistent interface for applications to interface with users.'
};
console.log(params);
FB.ui(params, function(obj) { console.log(obj);});
While logcat output shows this:
09-03 21:29:00.230: D/CordovaLog(21824): Error: Status=2 Message=Class not found
09-03 21:29:00.230: D/CordovaLog(21824): file:///android_asset/www/cordova-2.0.0.js: Line 938 : Error: Status=2 Message=Class not found
09-03 21:29:00.230: I/Web Console(21824): Error: Status=2 Message=Class not found at file:///android_asset/www/cordova-2.0.0.js:938
I don't know if this is an issue with facebook authentication of my app or some code issue. I have generated an Android Hash Key using the keytool and submitted it to facebook developer page. When I export my android project as android application in eclipse using the same keystore, it doesn't show me the alias I used with keytool (same keystore). So I created a new alias with the same alias name and password and then install the apk on my phone. What seems to be the issue here?
Well there were many problems. First of all, and most confusing was that the following line is not to be placed in plugins.xml but in config.xml instead.
<plugin name="com.phonegap.facebook.Connect" value="com.phonegap.facebook.ConnectPlugin" />
After that, I had not entered the correct hash key at facebook developer page. Since you don't want to export an apk through a keystore every time you need to test your app, you should just run the debugging apk generated by eclipse (Run as > Android application) and attempt FB.login(). Facebook will give you an error that your key is 'xxxxxx' and it does not match the keys listed at your app page. Note 'xxxxxxx' down and enter it on the facebook app page.
Others were my own mistakes of not including the scripts in the correct order. I had not followed the example carefully. Be sure you get the example/Simple/index.html working first before you code for your own application. Hope it helps...

Categories

Resources