For an application I'm building I would like to test if I have both read and write access on the customerkey, customersecret combination I receive.
Is there a specific function which is the least disrupting for testing write access? Or is creating and removing a product the adviced way to go?
You can try to create a Tax Class with missing fields. You'll get a validation error if the consumer key has write permission, vs an authorization error if it doesn't.
{
"code": "rest_missing_callback_param",
"message": "Missing parameter(s): name",
"data": {
"status": 400,
"params": [
"name"
]
}
}
vs
{
"code": "woocommerce_rest_authentication_error",
"message": "The API key provided does not have write permissions.",
"data": {
"status": 401
}
}
Related
I'm trying to learn how to use this query; I created an API key and used Postman to
Post https://www.googleapis.com/calendar/v3/freeBusy?key="THE_API_KEY"
with this request body:
{
"timeMin": "2022-11-16T00:00:31-00:00",
"timeMax": "2022-11-16T14:00:00-00:00",
"groupExpansionMax": 100,
"calendarExpansionMax": 50,
"items": [
{
"id": "MY_OWN_GMAIL_ADDRESS"
},
{
"id": "OTHER_GMAIL_ADDRESS"
}
]
}
and got this response:
{
"kind": "calendar#freeBusy",
"timeMin": "2022-11-16T00:00:31.000Z",
"timeMax": "2022-11-16T14:00:00.000Z",
"calendars": {
"MY_OWN_GMAIL_ADDRESS": {
"errors": [
{
"domain": "global",
"reason": "notFound"
}
],
"busy": []
},
"OTHER_GMAIL_ADDRESS": {
"errors": [
{
"domain": "global",
"reason": "notFound"
}
],
"busy": []
}
}
}
What am I missing?
The Freebusy: query returns information about weither or not there is an event at the time of the request.
This method does not require authorization when being used against a public google calendar. There are a number of such calendars the holiday calendars are all public. You could also set your own calendar to public if you wish and then you would be able to use use an api key to access it.
API keys give you access to public methods only.
In order to access private user data. You need to be authorized using oauth2 with one of the following scopes.
If you do not have access to a calendar then it will return not found as you cant see it so your not going to be able to find it.
The solution i your case to fix your issue would be to either set the calendar to public and continue to use the api key. You will only be able to preform read actions against the calendar.
Or to switch to using oauth2 and send an authorization header with a bearer token.
Your post didnt include the Authorization header. Did you include it in your Postman Request?
Your need to send your Access Token as a Bearer Token in the Authorization Header
You can see an example for a request here:
https://developers.google.com/calendar/api/v3/reference/freebusy/query?apix=true#try-it
I'm using GithubAuthProvider with the added scope repo to get the user's access token which is later used to access the GitHub GraphQL API (the GitHub App has the permissions for Contents and Metadata set to Read-only).
The problem is when I'm trying to list private repos. The API returns an empty array as if I don't have the required permissions. Moreover, when I try to list branches of a user's repo it returns an error of type FORBIDDEN.
Query:
query {
viewer {
repository(name: "some-repo") {
refs(refPrefix: "refs/heads/", first: 10) {
nodes {
name
}
}
}
}
}
Response:
{
"data": {
"viewer": {
"repository": {
"refs": null
}
}
},
"errors": [
{
"type": "FORBIDDEN",
"path": [
"viewer",
"repository",
"refs"
],
"extensions": {
"saml_failure": false
},
"locations": [
{
"line": 7,
"column": 7
}
],
"message": "Resource not accessible by integration"
}
]
}
What am I missing?
For GitHub GraphQL API, only scope repo may not be enough.
Following are scopes requested for reference. Authenticating with GraphQL
user
public_repo
repo
repo_deployment
repo:status
read:repo_hook
read:org
read:public_key
read:gpg_key
The API returns an empty array as if I don't have the required permissions.
I wonder whether you are query under the viewer. viewer can get the private repos he/she owned. For repos owned by other people, you can try
repository(name: "repo-name", owner: "login") {
name
}
It will return NOT_FOUND error if you don't have the required permissions.
Your query works fine for me :)
It turns out I read through the Firebase instructions too fast and created a Github App instead of an OAuth App.
It's now working as it should.
I am trying to create a new group and team via the Graph API. I am trying to run the POST a request in Graph Explorer (https://developer.microsoft.com/en-us/graph/graph-explorer) as below but get a bad request.
Request: POST
Version: v1.0
URL: https://graph.microsoft.com/v1.0/teams/groups
Request Body:
{
"displayName":"Flight 157",
"mailNickname":"flight157",
"description":"Everything about flight 157",
"visibility":"Private",
"groupTypes":["Unified"],
"mailEnabled":true,
"securityEnabled":false,
"members#odata.bind":[
"https://graph.microsoft.com/v1.0/users/957c07af-dcad-4b72-9306-1c4ee7d04e1f"
],
"owners#odata.bind":[
"https://graph.microsoft.com/v1.0/users/957c07af-dcad-4b72-9306-1c4ee7d04e1f"
]
}
I get the below response error:
{
"error": {
"code": "BadRequest",
"message": "Invalid bind property name members in request.",
"innerError": {
"request-id": "fee10382-5112-44f8-a8c9-683453bdf050",
"date": "2020-03-05T01:08:19"
}
}
}
I am not quite sure what I am doing wrong. Can anyone please help me with this?
I can't get User Activity from the Google Analytics Reporting API (v4) using a User ID.
Client ID (in a different, non-User ID view) works, however.
Am I missing something?
--
For Client ID
I go here in my Google Analytics web interface:
https://analytics.google.com/analytics/web/#/report/visitors-user-activity/a45743608w76484324p79062844/_u.date00=20190327&_u.date01=20190402&_r.userId=1142688158.1525244974
I get user activity details as expected:
--
I call the following:
POST https://analyticsreporting.googleapis.com/v4/userActivity:search?key={YOUR_API_KEY}
{
"viewId": "79062844",
"dateRange": {
"startDate": "2019-03-27",
"endDate": "2019-04-02"
},
"user": {
"type": "CLIENT_ID",
"userId": "1142688158.1525244974"
}
}
I get the expected response:
{
"sessions": [
…
],
"totalRows": 14,
"sampleRate": 1
}
--
For User ID
I go here in my Google Analytics web interface:
https://analytics.google.com/analytics/web/#/report/visitors-user-activity/a45743608w76484324p185098721/_u.date00=20190327&_u.date01=20190402&_r.userId=Not%20Logged%20In-
I get user activity details as expected:
--
I call the following:
POST https://analyticsreporting.googleapis.com/v4/userActivity:search?key={YOUR_API_KEY}
{
"viewId": "185098721",
"dateRange": {
"startDate": "2019-03-27",
"endDate": "2019-04-02"
},
"user": {
"type": "USER_ID",
"userId": "Not Logged In-"
}
}
I get an error instead:
{
"error": {
"code": 400,
"message": "USER_ID: Not Logged In- not found.",
"status": "INVALID_ARGUMENT"
}
}
--
I have tried different IDs, different dates, changing the type to CLIENT_ID, URL encoding the User ID, and User IDs with no spaces - no joy.
It seems this is indeed a bug which several others are also experiencing.
This bug can be +1'd and followed here:
https://issuetracker.google.com/issues/130161158
Edit: This has now been fixed.
From your URL, you are looking for an ID called Not%20Logged%20In- which is not a valid id. Its probably changing the id when you copy paste the URL.
Getting Error: Field Value validation failed in REQUEST_BODY: Data Processing Exception while processing fields [/author]
I have the "w_organization_social" permission in my app. I'm successfully getting the access token.
Can anyone help me what's going wrong?
Url: https://api.linkedin.com/v2/ugcPosts
Body:
{
"author":"urn:li:person:<id>",
"lifecycleState":"PUBLISHED",
"specificContent": {
"com.linkedin.ugc.ShareContent": {
"shareCommentary": {
"text":"Hello world"
},
"shareMediaCategory": "VIDEO",
"media":[{
"status":"READY",
"description": {
"text":"hello world"
},
"media":"urn:li:digitalmediaAsset:<asset_id>",
"title":{
"text":"hello world"
}
}]
}
},
"visibility":{
"com.linkedin.ugc.MemberNetworkVisibility":"PUBLIC"
}
}
Response:
{
"serviceErrorCode" : 100,
"message" : "Field Value validation failed in REQUEST_BODY: Data Processing Exception while processing fields [/author]",
"status" : 403
}
While getting access token, make sure that you pass r_liteprofile and w_member_social permissions in scope.
Then you have to send a GET request to https://api.linkedin.com/v2/me, to get the Lite Profile and you will get the ID from the response.
Use the ID you got from Lite Profile to generate Person URN,
eg: "urn:li:person:<ID>"