Using apiKey for huawei push notfications - push-notification

i configured apiKey in huawei console for PushKit and i want send push from web app to my android app, so i prepared following CURL:
problem is postman still return
{"error":"400 Bad Request, body is empty"}
when i'm trying to call url from any online curl console result is as following:
{
"msg": "Authentication Error",
"code": "80200001"
}
how can i authorize my request by apiKey?

UPDATE
"code": "80200001"
It's recommended that you check your appid in the URL.
This error code is usually caused by the appid in your URL is different from the appid used to obtain the access_token, or the appid has no permission.

Related

Getting 400 error while creating "Web Token" when hitting enterprises.webTokens.create endpoint to use iframe in EMM console

We are getting 200 success while hitting endpoints like create signup URL, create enterprise, create enrollment token etc. through API Explorer or Postman. But while we are trying to hit the "create web token" endpoint we are getting 400 error.
We are implementing Google Android Management API. Finally, we are proceeding for implementing iframe which required the web token as it's carrier. But we are failing to do so.
For your reference:
enrollmentTokens.create endpoint Link below:
https://developers.google.com/android/management/reference/rest/v1/enterprises.enrollmentTokens/create
In the API explorer we are providing
parent = enterprises/LC00x1u8p0 and selecting Google OAuth 2.0 credentials.
With this much information API Explorer giving 200 success message.
enterprises.webTokens.create endpoint Link below:
https://developers.google.com/android/management/reference/rest/v1/enterprises.webTokens/create
In the API explorer we are providing
parent = enterprises/LC00x1u8p0 and selecting Google OAuth 2.0 credentials.
With this the same information API Explorer giving 400 error. I have posted the error message and unable to understand where is the error coming.
Is our console cloud project need any special supplement for giving access to web token? or what exactly is the lacking that giving this 400 error?
We are failing to understand the error message. Please check the below response.
​{
"error": {
"code": 400,
"message": "domain: \"gdata.CoreErrorDomain\"\ncode: \"INVALID_VALUE\"\nargument: \"tokenSpec.parent\"\ndebug_info: \"code: INVALID_VALUE\\nhttp status: 400\\narguments: [tokenSpec.parent]\\nvalue: \\ncause: com.google.wireless.android.vending.enterprise.common.exceptions.InvalidParameterException: EnterpriseException{httpStatus=400, code=gdata.CoreErrorDomain.INVALID_VALUE, arguments=[tokenSpec.parent]}\\n\\tat com.google.wireless.android.vending.enterprise.common.exceptions.InvalidParameterException$Builder.build(InvalidParameterException.java:60)\\n\\tat com.google.wireless.android.vending.enterprise.business.EmbeddedUiServiceImpl.validate(EmbeddedUiServiceImpl.java:173)\\n\\tat com.google.wireless.android.vending.enterprise.business.EmbeddedUiServiceImpl.createWebToken(EmbeddedUiServiceImpl.java:123)\\n\\tat com.google.wireless.android.vending.enterprise.actions.mdmapi.EnterpriseActions$CreateWebTokenAction.execute(EnterpriseActions.java:360)\\n\\tat com.google.apps.framework.request.impl.InterceptorInvocation$Rpc.beforeProceed(InterceptorInvocation.java:147)\\n\\tat com.google.apps.framework.request.impl.InterceptorInvocation.proceed(InterceptorInvocation.java:158)\\n\\tat com.google.apps.framework.request.impl.RpcDispatcher.proceed(RpcDispatcher.java:136)\\n\\tat com.google.apps.framework.request.impl.RpcDispatcher.proceed(RpcDispatcher.java:42)\\n\\tat com.google.apps.framework.request.impl.AbstractDispatcher.doExecuteChainInternal(AbstractDispatcher.java:503)\\n\\tat com.google.apps.framework.request.impl.AbstractDispatcher.doExecuteChain(AbstractDispatcher.java:497)\\n\\tat com.google.apps.framework.request.impl.AbstractDispatcher.execute(AbstractDispatcher.java:331)\\n\\tat com.google.apps.framework.request.impl.AbstractDispatcher.executeAsync(AbstractDispatcher.java:254)\\n\\tat com.google.apps.framework.request.impl.RpcDispatcher.handleRpc(RpcDispatcher.java:126)\\n\\tat com.google.apps.framework.request.impl.RpcScopedHandlerFactoryImpl.run(RpcScopedHandlerFactoryImpl.java:276)\\n\\tat com.google.apps.framework.request.impl.RpcScopedHandlerFactoryImpl$2.handleRequest(RpcScopedHandlerFactoryImpl.java:126)\\n\\tat com.google.net.rpc3.impl.server.RpcServerInterceptor2Util$RpcApplicationHandlerAdaptor.handleRequest(RpcServerInterceptor2Util.java:82)\\n\\tat com.google.net.rpc3.impl.server.RpcServerInternalContext.runRpcInApplicationWithCancellation(RpcServerInternalContext.java:672)\\n\\tat com.google.net.rpc3.impl.server.RpcServerInternalContext.lambda$runRpcInApplication$0(RpcServerInternalContext.java:637)\\n\\tat io.grpc.Context.run(Context.java:536)\\n\\tat com.google.net.rpc3.impl.server.RpcServerInternalContext.runRpcInApplication(RpcServerInternalContext.java:637)\\n\\tat com.google.net.rpc3.impl.server.RpcServerChannel$4.apply(RpcServerChannel.java:1026)\\n\\tat com.google.net.rpc3.impl.server.RpcServerChannel$4.apply(RpcServerChannel.java:996)\\n\\tat com.google.common.util.concurrent.AbstractTransformFuture$TransformFuture.doTransform(AbstractTransformFuture.java:253)\\n\\tat com.google.common.util.concurrent.AbstractTransformFuture$TransformFuture.doTransform(AbstractTransformFuture.java:243)\\n\\tat com.google.common.util.concurrent.AbstractTransformFuture.run(AbstractTransformFuture.java:124)\\n\\tat com.google.common.context.ContextRunnable.runInContext(ContextRunnable.java:89)\\n\\tat com.google.common.context.ContextRunnable$1.run(ContextRunnable.java:78)\\n\\tat io.grpc.Context.run(Context.java:536)\\n\\tat com.google.tracing.GenericContextCallback.runInInheritedContext(GenericContextCallback.java:75)\\n\\tat com.google.common.context.ContextRunnable.run(ContextRunnable.java:74)\\n\\tat java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)\\n\\tat java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)\\n\\tat com.google.apps.framework.server.AbstractThreadPoolModule$InitializingThreadFactory.lambda$newThread$0(AbstractThreadPoolModule.java:416)\\n\\tat java.base/java.lang.Thread.run(Unknown Source)\\n\\n\"\n",
"status": "INVALID_ARGUMENT"
}
}
Thanks you very much for your attention. Any help to fix the issue is appreciable.
You need to supply the Request body of the enterprises.webTokens.create method. The request body contains an instance of WebToken.
Request body:
{
"parentFrameUrl": "<the URL of the page that will be hosting the iFrame>",
"enabledFeatures": [
"PLAY_SEARCH",
"PRIVATE_APPS",
"WEB_APPS",
"STORE_BUILDER"
],
"permissions": [
"APPROVE_APPS"
]
}
If successful, the response body contains a newly created instance of WebToken containing the value you need to embed the iFrame on the hosting page.

information needed on checking the google sign in and showing verification URL:

I am going through the https://developers.google.com/identity/sign-in/devices and i
am trying to get the code and verification URL as mentioned in the link using my CLIENT_ID which i have got from the cloud platform.
curl -d "client_id=CLIENT_ID&scope=email profile" https://accounts.google.com/o/oauth2/device/code
I am getting the below error:
{
"error": "invalid_client",
"error_description": "Invalid client type."
}
I am not getting the user_code and verification_url as a response.
Am I missing something?

How to get Access token via HTTP action in Flow

I'm trying to authenticate against an App Service that I have defined in Azure Active Directory. When accessing it, I first get the access token and the continue with the rest of the OAuth procedure.
The problem, however, is that I can only get the token when posting the request via Postman. When I try to call the same URL, with the same data using an HTTP action in flow, it fails:
{
"error": "invalid_client",
"error_description": "AADSTS70002: Error validating credentials. AADSTS50012: Invalid client secret is provided.\r\nTrace ID: 67250fbf-ad20-47f1-b3a3-dbce1e813600\r\nCorrelation ID: f9eaaa13-cee3-4f5c-a96a-6846c4392dd9\r\nTimestamp: 2018-01-17 12:21:51Z",
"error_codes": [
70002,
50012
],
"timestamp": "2018-01-17 12:21:51Z",
"trace_id": "67250fbf-ad20-47f1-b3a3-dbce1e813600",
"correlation_id": "f9eaaa13-cee3-4f5c-a96a-6846c4392dd9"
}
This is how it is set up in Flow:
When executed in Postman it works just fine:
I cannot figure out why this doesn't work when running the request from within a Flow. Am I missing something in the HTTP action card configuration?
Kind regards,
Peter
I found the reason for this not working. I had to fully URL encode the value for client_secret.
/Peter

Can't access FireBase Database via HTTP/REST error 403 Forbidden

Swift + Vapor framework for server + Xcode 8.1
I am trying to read Firebase Realtime Database making HTTP requests to my DB, but I get permission denied.
These are the steps:
1. create JWT sign it with secret key downloaded from "console.developers.google.com"
2. send POST request to OAuth2 server and get access token
3. send GET request to firebase database with access token received from OAuth2 server.
I get "Permission denied", HTTP/1.1 403 Forbidden
// the header of the JSON Web Token (first part of the JWT)
let headerJWT = ["alg":"RS256","typ":"JWT"]
// the claim set of the JSON Web Token
let jwtClaimSet =
["iss":"firebase-adminsdk-kxx5h#fir-30c9e.iam.gserviceaccount.com",
"scope":"https://www.googleapis.com/auth/firebase.database", //is this the correct API to access firebase database?
"aud":"https://www.googleapis.com/oauth2/v4/token",
"exp": expDate,
"iat": iatDate]
drop.get("access") { request in
var accesstoken = "ya29.ElqhA-....XXXX"
let responseFirebase = try drop.client.get("https://fir- 30c9e.firebaseio.com/data/Users.json",
headers: ["Authorization":"Bearer \(accesstoken)"],
query: [:])
print("FirebaseResponse_is \(responseFirebase)")
return "success"
}
TLDR; Try placing auth=<TOKEN> in your query string instead of using the authorization header.
The Firebase documentation is unclear on how this works. According to the documentation, there are three methods that should work.
auth=<TOKEN> in query string (link)
access_token=<TOKEN> in query string (link)
Authorization: Bearer <TOKEN> in request header (link)
I'm not convinced that all three methods do actually work however. I'm using method 1 in my application, so I know that one works for sure.
The scope key was missing value https://www.googleapis.com/auth/userinfo.email
let jwtClaimSet =
["iss":"firebase-adminsdk-kxx5h#fir-30c9e.iam.gserviceaccount.com",
"scope": "https://www.googleapis.com/auth/firebase.database
https://www.googleapis.com/auth/userinfo.email",
"aud":"https://www.googleapis.com/oauth2/v4/token",
"exp": expDate,
"iat": iatDate]
I found the answer browsing google groups here
headers: ["Authorization":"Authorization: Bearer \(accesstoken)"],
should be
headers: ["Authorization":"Bearer \(accesstoken)"],

How to authenticate WooCommerce REST API

I have generated the consumer key and consumer secret but I don't know how to aply it to authenticate on Postman. This is the screenshot below:
The url looks like this: https://mystore.com/wp-json/wc/v1/coupons?oauth_consumer_key=ck_XXXXXXXXXXXXXXX&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1471440398&oauth_nonce=Qaq8cK&oauth_version=1.0&oauth_signature=XXXXXXXXXXXXXXXXXXXXXXXXXw=
But this is returning error 401:
{
"code": "woocommerce_rest_cannot_view",
"message": "Sorry, you cannot list resources.",
"data": {
"status": 401
}
}
I have read the the documentation but it didn't show any examples.
You can send your credentials via Authentication header if your site runs on HTTPS (it should if you're running WooCommerce).
Here's the relevant part of the docs:
https://woothemes.github.io/woocommerce-rest-api-docs/?shell#authentication-over-https

Resources