Unable to make modifications to amplifyconfiguration.dart - flutter

Background
I have created a new flutter project and initialised amplify using amplify init then added an api using amplify add api
What am I trying to do?
I am trying to change my REST API from an authorizationType of AWS_IAM to API_KEY and I am following the instructions as described here: Amplify Flutter REST API
I manually change the amplifyconfiguration.dart file to change the authorizationType from AWS_IAM to API_KEY and specify my apiKey with the API key I setup via the AWS Console. I then execute a amplify push to push my changes to the cloud.
From
"UserAgent": "aws-amplify-cli/2.0",
"Version": "1.0",
"api": {
"plugins": {
"awsAPIPlugin": {
"testrestapi": {
"endpointType": "REST",
"endpoint": "https://xxxxxxxx.execute-api.ap-southeast-2.amazonaws.com/dev",
"region": "ap-southeast-2",
"authorizationType": "AWS_IAM"
}
}
}
}"
To
"UserAgent": "aws-amplify-cli/2.0",
"Version": "1.0",
"api": {
"plugins": {
"awsAPIPlugin": {
"testrestapi": {
"endpointType": "REST",
"endpoint": "https://xxxxxxxxx.execute-api.ap-southeast-2.amazonaws.com/dev",
"region": "ap-southeast-2",
"authorizationType": "API_KEY",
"apiKey":"<MY KEY>"
}
}
}
},"
Whats the problem?
After executing a amplify push command, the amplifyconfiguration.dart file reverts back to its original values.
Steps to reproduce
Create a new flutter project using flutter create
Initialise amplify via the amplify init command
Add an API via the amplify add api command
Open the project in an editor (eg Visual Studio Code), open amplifyconfiguration.dart and change the REST API details. Hit save.
Execute amplify push. The amplifyconfiguration.dart file will revert back to its original state.
How can I make changes to amplifyconfiguration.dart and make the changes persist? Alternatively how can I change my REST API fom the CLI as above? I have tried amplify update api but it does not allow me to change the authorizationType. The documentation states that I can make changes to the file manually but any changes dont seem to persist.
Any help would be greatly appreciated.

It's very easy, in the amplify console, go to the data tab and under the title (Data modeling) there is a gear symbol and a text that says: GraphQL API settings. Click and you can change the Default authorization mode option for the one you need. Then you update your project that you are working on.

Related

Create Azure Data factory linked service or integration runtime directly in git mode wit rest api

I am trying to create linkedservices with restapi in gitmode but the linked service is still created in live mode. My API code was
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataFactory/factories/{factoryName}/linkedservices/{linkedServiceName}?api-version=2018-06-01&versionType=branch&version=test_branch
with a body
"properties": {
"annotations": [],
"type": "AzureKeyVault",
"typeProperties": {
"baseUrl": "https://xxxxxxxxx.vault.azure.net/"
}
Please is there a way to reference the branch and create this service in git mode
As per official documentation, Changes made via PowerShell or an SDK are published directly to the Data Factory service, and are not entered into Git.
Refer - https://learn.microsoft.com/en-us/azure/data-factory/source-control

Programmatically configure Azure DevOps project settings

I'm looking for a way to automate/script Azure DevOps project creation. I know that I can use VSTeam PowerShell module to create a project, but it does not provide a way to programmatically set project settings (the ones on the screenshot below). Is there a way to do that with PowerShell or AZ CLI? In particular I'm looking for a way to control/change these two settings:
Limit job authorization scope to current project for non-release pipelines
Limit job authorization scope to referenced Azure DevOps repositories
You can try to use Rest API:
How to use PowerShell with rest API: Modify Azure Devops Test Case Parameters Through REST API
Rest API Methods: General Settings - Get; General Settings - Update
To create a project you will need to send a POST to https://dev.azure.com/<devopsOrgName>/_apis/projects?api-version=5.0-preview.3
with a body like the below. To get the "template type" value used in the body, you will need to set a GET to https://dev.azure.com/<devopsOrgName>/_apis/process/processes?api-version=5.0-preview.1
` {
"description": "Tailspin Toys",
"name": "Tailspin_TOYS",
"capabilities": {
"versioncontrol": {
"sourceControlType": "Git"
},
"processTemplate": {
"templateTypeId": "24268e03-7eed-4ac0-a178-700881565b99"
}
}
}`
To change specific settings, that you can't find in the documentation, I would suggest using the developer tools in your browser (f12). Watch the network tab and you should see the requests going when you change your setting.
In this instance, I can see the below request when I try these settings
URL: https://dev.azure.com/<devopsOrgName>/_apis/Contribution/HierarchyQuery
Type: POST
Body:
{ "contributionIds":["ms.vss-build-web.pipelines-general-settings-data-provider"],"dataProviderContext":{"properties":{"enforceJobAuthScopeForReleases":"false","sourcePage":{"url":"https://dev.azure.com/<devopsOrgName>/<projectName>/_settings/settings","routeId":"ms.vss-admin-web.project-admin-hub-route","routeValues":{"project":"<projectName>","adminPivot":"settings","controller":"ContributedPage","action":"Execute","serviceHost":"495d404e-cdeb-496a-8496-fccf9df3d9fa (<devopsOrgName>)"}}}} }
Azure DevOps REST isn't the most documented, but when used with your browser develop tools, I haven't found something I couldn't set.

GitHub API permission name for self-hosted GitHub Actions runners?

At the end of the day, I'm trying to implement the solution linked from here: Reuse Github Actions self hosted runner on multiple repositories. But the tutorials walk you though setting up a GitHub app in the UI, and I'm trying to do it via the API.
Context:
Creating a new "GitHub App" (not "OAuth App") in GitHub Enterprise v3.0 (soon migrating to v3.1).
Trying to do it entirely over the API and explicitly NOT the UI, by creating an "app manifest" (https://docs.github.com/en/enterprise-server#3.0/developers/apps/building-github-apps/creating-a-github-app-from-a-manifest).
Everything I've read about permissions on docs.github.com ends up pointing over to https://docs.github.com/en/enterprise-server#3.0/rest/reference/permissions-required-for-github-apps, which does not include the specific values that can be used with the API.
On a GHE instance, there is a large list of permissions available at a URL with this pattern:
https://{HOSTNAME}/organizations/{ORG}/settings/apps/{APP}/permissions
The specific permission I'm trying set says:
Self-hosted runners
View and manage Actions self-hosted runners available to an organization.
Access: Read & write
In the documentation (https://docs.github.com/en/enterprise-server#3.0/developers/apps/building-github-apps/creating-a-github-app-from-a-manifest#github-app-manifest-parameters) there is a parameter called default_permissions.
What is the identifier (key) to use for this permission, where the value is write?
I've tried:
the documented Self-hosted runners
the guess self-hosted runners
the guess self-hosted_runners
the guess self_hosted_runners
the guess selfhosted_runners
the guess runners
…but ultimately, the actual values which can be used here are (as far as I can tell after several hours of digging and guessing) undocumented.
actions:read and checks:read appear to work. Those are also undocumented, but I was able to figure it out by looking at the URLs, making an educated guess, and testing.
All of the tutorials I can find on the internet, including those on docs.github.com, all walk you through creating a new GitHub app via the UI. I am very explicitly trying to do this over the API.
Any tips? Have I missed something? Is this not available in GHE yet?
Here is my app manifest, redacted.
{
"public": true,
"name": "My app",
"description": "My app's description.",
"url": "https://github.example.com/my-org/my-repo",
"redirect_url": "http://localhost:9876/register/redirect",
"default_events": [],
"default_permissions": {
"actions": "read",
"checks": "read",
"runners": "write"
},
"hook_attributes": {
"url": "",
"active": false
}
}
WITH the "runners": "write" line, the error message I receive says:
Invalid GitHub App configuration
The configuration does not appear to be a valid GitHub App manifest.
× Error Default permission records resource is not included in the list
WITHOUT the "runners": "write" line, the submission is successful.
The GitHub team finally updated the documentation. The permission I was looking for was organization_self_hosted_runners.

SAP Cloud Platform : Basic Authentication showing when accessing service in WEB IDE app. Why?

I'm using a the same destination on a number of apps, which are connecting fine.
Created a new app (using the same SAP WEB IDE template).
The Service is retrieved fine when selecting New/OData service from the project menu, proving my Destination credentials are fine.
Now, when I run the app. I'm getting a basic authentication window. Cancelling this means I can't connect to the metadata of the service and therefore can't retrieve any data.
https://webidetesting0837185-s0015641139trial.dispatcher.hanatrial.ondemand.com/SAPUI5-ABAP-SFI/sap/opu/odata/sap/ZSV_SURVEY_SRV/$metadata?sap-language=EN 401 (Unauthorized)
My username and password is not being accepted even though it's correct.
Any ideas?
If you User/Password is not accepted I think you missing some configuration in the backend, check the logs like ST22 or SLG1 for authorization issues. Also check if your destinations in Cloud Connector work properly.
To solve this in generell not using basic authentication, you need to work with SAP CP's destination service. Retrieving from onPremise or via AppToAppSSO as Type/Mode of the destination OR work with API Service on SAP CP. For first way change (destination service) reference in your SAPUI5 instead of relative paths in neo-app.json like this:
{
"routes": [
{
"path": "/destinations/SFSF_ODATA_PROXY",
"target": {
"type": "destination",
"name": "sap_hcmcloud_core_odata"
},
"description": "SFSF Proxy OData"
}
],
"cacheControl": [
{
"directive": "public",
"maxAge": 0
}
]
}
Make sure you enter the credentials for your backend (and not for your CP account for example). You can also try and maintain the credentials in the destination itself by setting AuthenticationType as BasicAuthentication.
I have already solved this issue with change Authentication as Basic Authentication

How to run a firebase sample

I have cloned a firebase sample from here
https://github.com/firebase/quickstart-js
I want to run this sample, I have tried with itellij and gitbash but it doe not run
Messaging example
Install the Node.JS framework (here the link to download for your system). I show you how to do it with Linux but the procedure should be the same.
Using command-line install firebase CLI using the command: npm install -g firebase-tools (may need sudo if it fails).
Type firebase login. This will open your browser and let you login to your Google account.
Download the repository with git clone https://github.com/firebase/quickstart-js.git
Enter repo directory cd quickstart-js
Go to Firebase console here and then Create new project
In the dashboard of your project click on Add Firebase to your web application and copy the javascript code that is prompted to you.
Open index.html in messaging folder and at line 83 paste the code copied from dashboard.
Type command firebase init in messaging folder and then answer the questions that will be asked you:
What Firebase CLI features do you want to setup for this folder?
--> Hosting: Configure and deploy Firebase Hosting sites
What file should be used for Database Rules?
--> Blank, it is not relevant for this example.
What do you want to use as your public directory? (public)
--> .
Configure as a single-page app (rewrite all urls to /index.html)?
--> y
File ./index.html already exists. Overwrite?
--> N
Type command firebase serve -p 8081 (or any other free port you have)
Go to http://localhost:8081/index.html
Click Request permission (the registration token will appear if the operation succeed)
In another tab go to https://console.firebase.google.com/project/_/settings/cloudmessaging, select your project and save the server key (the long one)
Type
curl -X POST -H "Authorization: key=YOUR-SERVER-KEY" -H "Content-Type:
application/json" -d '{
"notification": {
"title": "Portugal vs. Denmark",
"body": "5 to 1",
"icon": "firebase-icon.png",
"click_action": "http://localhost:8081"
},
"to": "YOUR-IID-TOKEN"
}' "https://fcm.googleapis.com/fcm/send"
replacing YOUR-SERVER-KEY with the copied server key and YOUR-IID-TOKEN with the string appeared here after clicking on Request permission. If everything is done correctly a notification will appear in the local page in this form
Received message:
{
"from": "xxxxxxxxxx",
"collapse_key": "do_not_collapse",
"notification": {
"title": "Portugal vs. Denmark",
"body": "5 to 1",
"icon": "firebase-icon.png",
"click_action": "http://localhost:8081"
}
}
Database example
You don't need to run firebase init because the firebase.json file is already present and configured in the repository.
But if you want to use it you have to:
Paste you credentials (same of the previous step 7) in the head section of index.html page.
Go to firebase dashboard --> your project --> Authentication --> Authentication Method, and choose the method you want (email/password, google, etc.)
In quickstart-js/database folder type command firebase serve and the application will be loaded to this page.
Go to that page and click on Sign in with Google, type your credential, and enjoy it! :-)
Auth example
You don't need to run firebase init because the firebase.json file is already present and configured in the repository.
To use it (I've not tried it) with facebook for example you should:
Paste your credentials in facebook-credentials.html in head section
In the script section at the end of that page paste <YOUR_FACEBOOK_APP_ID>
Type in folder quickstart-js/auth the command firebase serve and the application will be loaded to this page.
Go to localhost:5000 and click on Facebook Login using OAuth Credentials (via Facebook Login Button) to login.
If you want to use other methods you'll have to modify the corresponding file in the same way (facebook-popup.html, facebook-redirect, etc.)
Feel free to ask if it is not clear.