Google Drive API insert permission only returns id - permissions

I'm using this request to grant user permission for a folder
https://www.googleapis.com/drive/v2/files/{{id}}/permissions?sendNotificationEmails=true&fields=emailAddress,id,name,role,type,value
but it returns only the id field
{ id: '0123456789876543210' } like this
How can I get all other information in response ? or,
is there any BUG in Drive REST API ?

From the documentation here https://developers.google.com/drive/v2/reference/permissions/list:
The return resource is in the following form:
{
"kind": "drive#permissionList",
"etag": etag,
"selfLink": string,
"items": [
permissions Resource
]
}
Which means you would need to specify your query field param as
items(emailAddress,id,name,role,type,value)
Rather than:
emailAddress,id,name,role,type,value
Alternatively, you can leave the fields param out to ensure you actually have the information available. Hope that helps!

Related

How to map API response to output claims in B2C custom policy?

I have use Technical Profile in B2C custom policy to call REST API and it returned format like this
{
"value": [
{
"id":"00000000000"
"name": "",
}
]
}
So in case how to get id and map it to output claim ? Please let me know a way to do it, I have investigated but I can not find out a solution so far
Did you try this?
https://learn.microsoft.com/en-us/azure/active-directory-b2c/json-transformations#getclaimfromjson
You want to extract value.0.id
Here you can see example json:
https://github.com/azure-ad-b2c/unit-tests/blob/main/claims-transformation/json/CT_GetClaimFromJson.xml

Is it possible to read google sheets *metadata* only with API key?

It is possible to read data from a sheet only with API key (without OAuth 2.0), but it seems that reading the developer metadata requires OAuth 2.0.
Is there some way to read the metadata from an app without asking the user to connect his google account?
You want to retrieve the developer metadata of the Spreadsheet using the API key.
You have already been able to get values from Spreadsheet using the API key.
If my understanding is correct, how about this answer? Please think of this as just one of several possible answers.
Issue and workaround:
Unfortunately, "REST Resource: spreadsheets.developerMetadata" in Sheets API cannot be used with the API key. In this case, OAuth2 is required as mentioned in your question. The developer metadata can be also retrieved by the method of spreadsheets.get in Sheets API. The developer metadata can be retrieved by the API key. And in this method, all developer metadata is retrieved. So when you want to search the developer metadata, please search it from the retrieved all developer metadata.
IMPORTANT POINTS:
In this case, please set the visibility of developer metadata to DOCUMENT. By this, the developer metadata can be retrieved by the API key. If the visibility is PROJECT, it cannot be retrieved with the API key. Please be careful this.
When you want to retrieve the developer metadata with the API key, please publicly share the Spreadsheet. By this, it can be retrieved with the API key. Please be careful this.
Sample situation 1:
As a sample situation, it supposes that it creates new Spreadsheet, and create new developer metadata to the Spreadsheet as the key of "sampleKey" and value of "sampleValue".
In this case, the sample request body of spreadsheets.batchUpdate is as follows.
{
"requests": [
{
"createDeveloperMetadata": {
"developerMetadata": {
"location": {
"spreadsheet": true
},
"metadataKey": "sampleKey",
"metadataValue": "sampleValue",
"visibility": "DOCUMENT"
}
}
}
]
}
Sample curl command:
When you retrieve the developer metadata from above sample Spreadsheet, please use the following curl command.
curl "https://sheets.googleapis.com/v4/spreadsheets/### spreadsheetId ###?key=### your API key ###&fields=developerMetadata"
In this case, fields=developerMetadata is used to make it easier to see the response value. Of course, you can also use * as fields.
In this case, when above endpoint is put to the browser, you can see the retrieved value, because of GET method.
Result:
{
"developerMetadata": [
{
"metadataId": 123456789,
"metadataKey": "sampleKey",
"metadataValue": "sampleValue",
"location": {
"locationType": "SPREADSHEET",
"spreadsheet": true
},
"visibility": "DOCUMENT"
}
]
}
Sample situation 2:
As other situation, it supposes that it creates new Spreadsheet, and create new developer metadata to the 1st column (column "A") as the key of "sampleKey" and value of "sampleValue".
In this case, the sample request body is as follows.
{
"requests": [
{
"createDeveloperMetadata": {
"developerMetadata": {
"location": {
"dimensionRange": {
"sheetId": 0,
"startIndex": 0,
"endIndex": 1,
"dimension": "COLUMNS"
}
},
"metadataKey": "sampleKey",
"metadataValue": "sampleValue",
"visibility": "DOCUMENT"
}
}
}
]
}
Sample curl command:
When you retrieve the developer metadata from above sample Spreadsheet, please use the following curl command.
curl "https://sheets.googleapis.com/v4/spreadsheets/### spreadsheetId ###?key=### your API key ###&fields=sheets(data(columnMetadata(developerMetadata)))"
In this case, sheets(data(columnMetadata(developerMetadata))) is used to make it easier to see the response value. Of course, you can also use * as fields.
Result:
{
"sheets": [
{
"data": [
{
"columnMetadata": [
{
"developerMetadata": [
{
"metadataId": 123456789,
"metadataKey": "sampleKey",
"metadataValue": "sampleValue",
"location": {
"locationType": "COLUMN",
"dimensionRange": {
"dimension": "COLUMNS",
"startIndex": 0,
"endIndex": 1
}
},
"visibility": "DOCUMENT"
}
]
},
{},
,
,
]
}
]
}
]
}
References:
Method: spreadsheets.developerMetadata.get
DeveloperMetadataVisibility
If I misunderstood your question and this was not the direction you want, I apologize.

How to get user info (role) from loopback token from client after login

I have a instance of User and instance of Role attached to it. Both are basic models provided from Loopback and they show up in RoleMapping and they work in ACL fine.
So, lets say I logg user in from my Vue client, then I get the response containing the access token in id field so I can make further auth requests, how do I then retrieve basic user info from that access token. Is there a way of parsing it or should I somehow modify the /login remote hook?
Any thoughts?
you need to call the login api with "include" option
/api/users/login?include=User
in response you will get something like this
{
"id": "CZY4lbJbJ2J6DrEIAjYAHfTEZbLMC2tWpyM7sZaKs7rZ1PhIY3mycua0kOHlDXfR",
"ttl": 1209600,
"created": "2018-01-21T17:01:20.183Z",
"userId": "5a3e614339e67f0e580642af",
"user": {
"createdAt": "2017-12-23T13:59:31.314Z",
"email": "dummy#dummy.co",
"id": "5a3e614339e67f0e580642af",
"name": "dummy",
}
you can try it in explorer

Create MasterCard tokenization API

I have a mobile app containing payment method via MasterCard. I have this tutorial:
https://ap-gateway.mastercard.com/api/documentation/apiDocumentation/rest-json/version/latest/api.html?locale=en_US
I want to create Tokenization which contains customer's master detail, I have followed this tutorial part:
https://ap-gateway.mastercard.com/api/documentation/apiDocumentation/rest-json/version/latest/operation/Tokenization%3a Create or Update Token (with system-generated token).html?locale=en_US
I tried with :
POST https://ap-gateway.mastercard.com/api/rest/version/41/merchant/{{MyMerchantID}}/token
Params:
{
"sourceOfFunds": {
"type": "CARD",
"provided": {
"card":{
"number": "5123450000000008",
"expiry": {
"month": "05",
"year": "17"
}
}
}
Note: The number is a mastercard test number.
I am always get this error:
error
cause "INVALID_REQUEST"
explanation "Invalid credentials."
result "ERROR"
I followed the params in second URL.
Can anyone help? Are the params correct or I missed something?
In your configuration file, you need to set the following:
$configArray["merchantId"] = "[merchantId]";
// API username in the format below where Merchant ID is the same as above
$configArray["apiUsername"] = "merchant.[merchantId]";
// API password which can be configured in Merchant Administration
$configArray["password"] = "your api password";
Setting the above parameters in the config file will solve your problem
Try replacing "ap-gateway" with the real gateway provided for you. Your merchantID is not supported in test gateway.
First, you should ask you bank to enable the tokenization for your merchant account
POST
https://ap-gateway.mastercard.com/api/rest/version/61/merchant/{{MyMerchantID}}/token
you have to set Authorization->Basic Auth
Username : Your_MerchantID
Password : ApiPassword
Params:
{
"session": {
"id": "SESSION0002510583427E2239608H32"
}
}

Google youtube api v3 does not return part "brandingSettings"

I am trying to extract the banner-image used in a certain youtube channel programmatically.
As far as I know it is to be in the brandingSettings, to be exact I think it is brandingSettings.image.bannerImageUrl, see here for an indetail description of the API:
https://developers.google.com/youtube/v3/docs/channels
So, I suppose I should be able to get that information with a GET request like this:
https://www.googleapis.com/youtube/v3/channels?part=brandingSettings&key=[YOURAPIKEY]&forUsername=esltv
But that request (replacing the [YOURAPIKEY] with my actual key of course) returns without the desired part "brandingSettings":
{
"kind": "youtube#channelListResponse",
"etag": "\"79S54kzisD_9SOTfQLu_0TVQSpY/WJfuNLYVgEQVEhWQ-03PpQlCyzo\"",
"pageInfo": {
"totalResults": 1,
"resultsPerPage": 5
},
"items": [
{
"kind": "youtube#channel",
"etag": "\"79S54kzisD_9SOTfQLu_0TVQSpY/GwL7oIruOCBr66yiNtrJqE3_Drs\"",
"id": "UC0G2qz-hoaCswQNgoWU_LTw"
}
]
}
I currently have turned on "YouTube Data API v3" in google api console.
Am I missing some permission, or does the channel somehow not suit in regard of retrieving its brandingSettings?
BRs,
Sebastian
for Username is actually for you to get the channelId. channels.list actually depends on channelId.
So with your first request you get channelID back, then do the same request second time, use channelId instead of username. (If you already know channelID use it first time as well.)
GET https://www.googleapis.com/youtube/v3/channels?part=brandingSettings&id=UC0G2qz-hoaCswQNgoWU_LTw&key={YOUR_API_KEY}