How can i get specific metamask permission? - permissions

I want to get restricted method permission, like eth_accounts. I found only 'eth_accounts' example in Metamask documentation
Provider.request({
method: "wallet_requestPermissions",
params: [
{
eth_accounts: {},
},
],
})

Related

Shopify add cart properties. How do this properties work? It disappears after page refresh

I am setting properties when adding to cart.
Ex:
var formdata=[
"items":{
id:123456,
quantity:1
properties:{'flag':true}
}
];
added using api : /cart/add.js
Details I get from cart.js without refresh
response from : /cart/add.js and cart.js
[
{
"id": 32423423423423,
"properties": {
"flag": true
},
"quantity": 1,
"variant_id": 42705234345345,
}
]
The above items get added successfully to cart. After adding I again fetch the cart details and It has this properties value.But when I refresh the page cart items properties does not have any value.
Ex Currently I am getting this only when page is refreshed:
response from cart.js after page refresh
properties:{
Ref: 0
}
What this properties is?
Why is this happening? If worked, will this properties be available on order create webhook? It only disappears when refreshed. Moreover main reason to add this properties is to receive this properties in order-create webhook to distinguish from normal order. If anyone having other alternative please suggest.
Adding a product to the cart like so:
fetch('/cart/add.js', {
method: "post",
headers: {
"content-type": "application/json"
},
body: JSON.stringify({
items: [
{
quantity: 1,
id: 33116507373620,
properties: {
'flag': true
}
}
]
})
})
And getting the cart.js like so:
fetch('/cart/add.js').then(res => res.json()).then(res => console.log(res))
Will get you result like so:
{
...
"items": [
{
"id": 33116507373620,
"properties": {
"flag": true
},
"quantity": 1,
...
}
],
...
}
From there on what you are doing to not get this result I'm not sure, since this is working/tested and there is no issue.
Please double check if you are targeting the correct object once you get the cart.js response. (there is no properties direct object, it's under items[0].properties in this case)

How to update the Strapi GraphQL cache, after creating new data?

How to update the cache, after creating new data?
Error message from Apollo
Store error: the application attempted to write an object with no provided id but the store already contains an id of UsersPermissionsUser:1 for this object. The selectionSet that was trying to be written is:
{
"kind": "Field",
"name": { "kind": "Name", "value": "user" },
"arguments": [],
"directives": [],
"selectionSet": {
"kind": "SelectionSet",
"selections": [
{ "kind": "Field", "name": { "kind": "Name", "value": "username" }, "arguments": [], "directives": [] },
{ "kind": "Field", "name": { "kind": "Name", "value": "__typename" } }
]
}
}
Nativescript-vue Front-end Details
1- Watch Book Mobile app in action on YouTube: https://youtu.be/sBM-ErjXWuw
2- Watch Question video for details on YouTube: https://youtu.be/wqvrcBRQpZg
{N}-vue AddBook.vue file
apolloClient
.mutate({
// Query
mutation: mutations.CREATE_BOOK,
// Parameters
variables: {
name: this.book.name,
year: this.book.year,
},
// HOW TO UPDATE
update: (store, { data }) => {
console.log("data ::::>> ", data.createBook.book);
const bookQuery = {
query: queries.ALL_BOOKS,
};
// TypeScript detail: instead of creating an interface
// I used any type access books property without compile errors.
const bookData:any = store.readQuery(bookQuery);
console.log('bookData :>> ', bookData);
// I pin-pointed data objects
// Instead of push(createBook) I've pushed data.createBook.book
bookData.books.push(data.createBook.book);
store.writeQuery({ ...bookQuery, data: bookData })
},
})
.then((data) => {
// I can even see ID in Result
console.log("new data.data id ::::: :>> ", data.data.createBook.book.id);
this.$navigateTo(App);
})
.catch((error) => {
// Error
console.error(error);
});
What are these "Book:9": { lines in the cache?
console.log store turns out:
"Book:9": {
"id": "9",
"name": "Hadi",
"year": "255",
"__typename": "Book"
},
"$ROOT_MUTATION.createBook({\"input\":{\"data\":{\"name\":\"Hadi\",\"year\":\"255\"}}})": {
You can see all front-end GitHub repo here
Download Android apk file
Our goal is to update the cache. Add Book Method is in here:
https://github.com/kaanguru/mutate-question/blob/c199f8dcc8e80e83abdbcde4811770b766befcb5/nativescript-vue/app/components/AddBook.vue#L39
Back-end details
However, this is a frontend question a running Strapi GraphQL Server is here: https://polar-badlands-01357.herokuapp.com/admin/
GraphQL Playground
USER: admin
PASSWORD: passw123
You can see GraphQL documentation
I have so much simple Strapi GrapQL Scheme:
If you want to test it using postman or insomnia you can use;
POST GraphQL Query URL: https://polar-badlands-01357.herokuapp.com/graphql
Bearer Token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MSwiaWF0IjoxNTkwODI3MzE0LCJleHAiOjE1OTM0MTkzMTR9.WIK-f4dkwVAyIlP20v1PFoflpwGmRYgRrsQiRFgGdqg
NOTE: Don't get confused with $navigateTo() it's just a custom method of nativescript-vue.
It turns out;
all code was correct accept bookData.push(createBook);
// HOW TO UPDATE
update: (store, { data }) => {
console.log("data ::::>> ", data.createBook.book);
const bookQuery = {
query: queries.ALL_BOOKS,
};
// TypeScript detail: instead of creating an interface
// I used any type access books property without compile errors.
const bookData:any = store.readQuery(bookQuery);
console.log('bookData :>> ', bookData);
// I pin-pointed data objects
// Instead of push(createBook) I've pushed data.createBook.book
bookData.books.push(data.createBook.book);
store.writeQuery({ ...bookQuery, data: bookData })
},
})
Typescipt was helping
The point is; I shouldn't trust TypeScript errors, or at least I should read more about what it really says.
Typescript just asked me to be more specific while saying: Property 'push' does not exist on type 'unknown'
TypeScript was trying to tell me I need to be more specific while calling ROOT_MUTATION data. It said: Cannot find name 'createBook' But again I ignored it.
Solution Github Branch
https://github.com/kaanguru/mutate-question/tree/solution
Sources
how to update cache
Create interface for object Typescript

nuxt-auth setting user object after login

im using the nuxt-auth module.
I've got it to work so far. I am able to login properly.
But whenever i login, the user object in my store does not get set.
It seems like my API is getting called without parameters so it does not know which user to set.
nuxt.config.js
auth: {
redirect: {
login: '/login',
logout: '/login',
callback: '/login',
home: '/'
},
strategies: {
local: {
endpoints: {
login: {
url: 'token',
method: 'post',
propertyName: 'token'
},
user: {
url: 'microservice/user',
method: 'get',
propertyName: false
},
logout: false
}
},
watchLoggedIn: true,
resetOnError: true
}
},
logging in
await this.$auth.loginWith('local', {
data: {
username: this.username,
password: this.passwort
}
})
example API-User
{
"method": "GET",
"path": "/user/102",
"query": "",
"response": {
"type": "single",
"payload": {
"id": 102,
"firstname": "super",
"name": "test",
"username": "stest1",
//some data
}
}
}
After retrieving a token and setting it, my app sends a request without query/parameters to my user-API. Either im doing something wrong, or am just too dumb too see the right way to set my user. However, if i set my user-Route to for example 'microservice/user/102' it is able to retrieve that one specific user.
Hoping anyone can help! :D
I think you should set it propertyName for user endpoint
user: {
url: 'microservice/user',
method: 'get',
propertyName: payload
},

How to request popup-auth-window on open google-spreadsheet to get user e-mail?

I tryed to get email (Session.getActiveUser().getEmail()), but i should to ask user permission:
// it script on google script
function onOpen() {
Logger.log(Session.getActiveUser().getEmail())
Logger.log(Session.getEffectiveUser().getEmail())
}
// it's manifest for access
{
"timeZone": "Europe/Moscow",
"dependencies": {
},
"exceptionLogging": "STACKDRIVER",
"oauthScopes": [
"https://www.googleapis.com/auth/spreadsheets.currentonly",
"https://www.googleapis.com/auth/spreadsheets",
"https://www.googleapis.com/auth/userinfo.email",
"https://www.googleapis.com/auth/script.scriptapp"
]
}
How I should to request auth-window?

Error when paying with iDeal: "Signature not supplied"

I set up a test account with Adyen. I try to make a payment through the test API. The following payload is given to the following endpoint:
https://checkout-test.adyen.com/v37/payments
Payload / body:
{
amount: {
currency: "EUR",
value: price
},
countryCode: "NL",
shopperLocale:"nl_NL",
reference: description,
paymentMethod: {
type: "ideal"
},
returnUrl: "https://xxx.nl",
merchantAccount: "xxxxx"
}
A response is returned with the redirect url, as expected. When I go to that URL, I can choose between different banks as expected. Only, when I choose a bank to pay with, the page tells me Error: Signature not supplied. What does this mean? What must I do to finalize my test payment succesfully?
The Checkout API expects you to provide the UI/Visuals for selecting and collecting details of payment methods. This mean you will need you to collect the shopper's choice of ideal bank.
You can determine the required fields from /paymentMethods.
Returned from /paymentMethods
{
"paymentMethods":[{
"name":"iDEAL",
"type":"ideal",
"details":[{
"key":"issuer",
"type":"select",
"items":[{
"name":"Test Issuer",
"id":"1121"
},
...
]
}]
},
...
]
}
Presuming you select the "Test Issuer", your payload/body would include a paymentMethod.issuer of 1121
{
amount: {
currency: "EUR",
value: price
},
countryCode: "NL",
shopperLocale:"nl_NL",
reference: description,
paymentMethod: {
type: "ideal",
issuer: "1121"
},
returnUrl: "https://xxx.nl",
merchantAccount: "xxxxx"
}