Good day all,
I am having problems adding Rest Services to mdm-admin
I had some troubles with mdm-android-* I created the service and reference in the permission.xml file
Creating a rest service in mdm-admin it has sefinitin as below
#GET
#Path("{type}/{id}/logs")
public List<? extends Application> getDeviceLogs(
#PathParam("type") String type,
#PathParam("id") String id)
throws MDMAPIException {
List<Application> applications;
ApplicationManagementProviderService appManagerConnector;
DeviceIdentifier deviceIdentifier = new DeviceIdentifier();
try {
deviceIdentifier.setType(type);
deviceIdentifier.setId(id);
appManagerConnector = MDMAPIUtils.getAppManagementService();
applications = appManagerConnector.getApplicationListForDevice(deviceIdentifier);
} catch (ApplicationManagementException e) {
String msg = "Error occurred while fetching the apps of the device.";
log.error(msg, e);
throw new MDMAPIException(msg, e);
}
return applications;
}
}
It is a clone of the get list of application method with just the path and function name changed.
When I deploy it. my webapp returns a 404 error status Code. when I try to call the function
To replicate this, Download v2.0.1 Open with Netbeans, Modify WSO2 MDM - Mobile Device Management Admin Services
Copy and paste one of the rest functions, rename the function Deploy and call that new function
How can I resolve this?
Your code snippet is working for me without any issue. You need to add permission entry in permission.xml as follows to make this work
<Permission>
<name>log device</name>
<path>/device-mgt/emm-admin/devices/logs</path>
<url>/operations/*/*/logs</url>
<method>GET</method>
</Permission>
The curl command I used is as below. don't forget to add a content type as application/json.
curl -X GET -H "Content-Type: application/json" -H "Authorization: Bearer 3c28103c1992c9e57d7091fb9f38732e" -k -v https://localhost:9443/mdm-admin/operations/android/000000000000000/logs
You are getting the 404 since you have to included the nely aded rest api permission to the user.
Please include the related permission to the one of the user's role and try that again.
Reffer to the documentation for more info.
Related
I was following the steps mentioned in the documentation for django rest framework.
I'm not able to proceed from step 4.
As mentioned in the documentation,
curl -X POST -d "grant_type=password&username=<user_name>&password=<password>" -u"<client_id>:<client_secret>" http://localhost:8000/o/token/
I have changed the above variables with my values.
curl -X POST -d "grant_type=password&username=admin&password=admin123" -u "5hKeHNtF3EKy3uCpJqaAe3mU2bGZTgJhsKKxIuAQ:pbkdf2_sha256$390000$VFcCOjIZkBFObellddDgKA$DXovC1UiuxRQ0KN/lARIdQmXcj8dnoJofkznmkkqsZY=" http://localhost:8000/o/token/
I tried to import the curl on postman and Im getting this error
Then I tried running the curl on Insomnia testing tool, and I got the request configured as in the screenshot.
Then I click send and I got an error
SO i changed 'Content-Type' to 'Form URL Encoded'
Now I'm geting an error
{
"error": "invalid_client"
}
I tried running the curl in shell also, and I'm getting an invalid syntax error
I'm stuck with this and don't know how to proceed with this. Please lend me a hand.
Thanks in advance...
I was using the hashed value for client_secret instead of the actual value.
How to get actual client_secret actual value?
Answer:
While creating new application, copy the Client secret before saving
the values
https://github.com/jazzband/django-oauth-toolkit/issues/1193
I'm creating a simple lambda function in AWS and wiring it with API gateway.
The issue, I'm having is that I'm getting "Missing Authentication Token" error response, while trying to reach created resource via HTTP, even I have "Authorization: NONE" defined in resource settings.
Here are the resource details:
Any reason, why Authorization option ignored? Did anyone had similar issue before?
Make sure you use the correct URL path for your stage. (Also make sure you deployed)
From the image above is how you can get the correct url.
I have the similar issue:
I have a public gateway "GET" API, which is working perfectly if I directly open it from the browser without authorization. But I get the 403 "Missing Authentication Token" error when I called it directly from a Java code:
HttpsURLConnection conn = (HttpsURLConnection) url.openConnection();
conn.setDoOutput(true);
conn.setRequestMethod("GET");
conn.setRequestProperty("Content-Type", "application/json");
//conn.setRequestProperty("Authorization", myJWTToken);
String result = getResponse(conn, mapper);
System.out.println(result);
But I succeed in Java when I removed that conn.setDoOutput(true) line
I have setup a new account and not verified my domain. I would like to test and confirm mail-send before proceeding with verification and adding payment information.
I have tried curl using the sandbox method and api key (including smtp). I have also tried to use my domain using the top account mail-address as recipient. But each time the send command (both curl and smtp) I get "Mailgun Magnificent API" response - but no mail is delivered. So far the Mailgun API does not look so Magnificent... I have gone through the documentation multiple times and cannot find what I might be doing wrong..
Any help is much appreciated.
Faced the same issue while sending emails via api by php curl. I solved it by changing API Base URL https://api.mailgun.net/v3/YOUR_DOMAIN_NAME to https://api.mailgun.net/v3/YOUR_DOMAIN_NAME/messages.
It's because their api is not only for sending.
Hope this helps.
For anyone else trying to figure out what "Mailgun Magnificent API" means in a Mailgun HTTP 200-OK API response, it occurs when posting to https://api.mailgun.net/v3/YOUR_DOMAIN_NAME/some/api/endpoint when /some/api/endpoint is not a valid Mailgun API endpoint.
If you are using a client library, there's probably a mistake in your Mailgun sender domain setting. Say you've verified the domain mg.example.com with Mailgun. Examples that can result in "Mailgun Magnificent API" (the exact setting name depends on the library):
MAILGUN_DOMAIN = mg.example.com # comment—this is a common mistake in dotenv files, which don't usually support inline comments; move the # comment to its own line
MAILGUN_DOMAIN = mg.example.com/mysite—get rid of the /mysite part
If you are posting directly to the Mailgun API (or developing a client library), there are some additional ways you might get "Mailgun Magnificent API":
Omitting the API endpoint: https://api.mailgun.net/v3/mg.example.com (as noted in another response)
Misspelling the endpoint: https://api.mailgun.net/v3/mg.example.com/massages (that should be messages with an e)
Including a # or ? after your domain: https://api.mailgun.net/v3/mg.example.com #/messages (see the note above about comments in config files)
Including an extra path after your domain: https://api.mailgun.net/v3/mg.example.com/route/to/my/app/messages
Note that you won't see "Mailgun Magnificent API" if YOUR_DOMAIN_NAME is not a valid sending domain you've registered with Mailgun. (In that case, Mailgun instead responds 404-Not Found).
The mailgun guide shows you to use https://api.mailgun.net/v3/YOUR_DOMAIN as YOUR_DOMAIN_NAME as in the snippet below and this was the problem.
If you're using mailgun-js, you simply need to have YOUR_DOMAIN as YOUR_DOMAIN_NAME.
No need for the https://api.mailgun.net/v3 part
const API_KEY = 'YOUR_API_KEY';
const DOMAIN = 'YOUR_DOMAIN_NAME';
const mailgun = require('mailgun-js')({apiKey: API_KEY, domain: DOMAIN});
const data = {
from: 'Excited User <me#samples.mailgun.org>',
to: 'foo#example.com, bar#example.com',
subject: 'Hello',
text: 'Testing some Mailgun awesomeness!'
};
mailgun.messages().send(data, (error, body) => {
console.log(body);
});
The problem for me was not including my domain name in the url and trying to type everything onto a single line. Strictly following their online example. Typing a backslash will bring your cursor to a new line.
$ curl -s --user 'api:key-xxx' \
https://api.mailgun.net/v3/your_domain/messages \
-F from='User <user#sample.mailgun.org>' \
-F to='xxx#gmail.com' \
-F subject='Hello' \
-F text='Testing some mailgun!'
Response
{
"id": "<xxx.x.xxx#your_domain>",
"message": "Queued. Thank you."
}
Including an slash "/" after messages url part at the end causes this failure too.
For example if you are using a library like Refit for c#, ensure your service interface be declared like this (see the Post attribute):
public interface IMailgunService
{
[Post("")]
Task<JsonDocument> SendEmailAsync([Body(BodySerializationMethod.UrlEncoded)] Dictionary<string, object> data);
}
I feel like I am banging my head against the wall here. I have created some custom objects and one custom action. To submit, I must successfully submit the action.
I use the following code from the "Get Code" button on the OpenGraph page in the developer site.
curl -F 'access_token=MY_ACCESSS_TOKEN' \
-F 'content=http://samples.ogp.me/417795554977717' \
'https://graph.facebook.com/me/myapp:myaction'
I get the following response
{"error":
{
"message":"(#15) This method must be called with an app access_token.",
"type":"OAuthException",
"code":15
}
}
Well, I like to think I'm a smart guy. I figure out how to generate my app access token from this guide and try again.
curl -F 'access_token=MY_APP_ACCESSS_TOKEN' \
-F 'content=http://samples.ogp.me/417795554977717' \
'https://graph.facebook.com/me/myapp:myaction'
And then I get this response.
{"error":
{
"message":"A user access token is required to request this resource.",
"type":"OAuthException",
"code":102
}
}
So I'm clearly in a never ending loop. I've banged my head against this, every which way.
Well of course as soon as I submit, I find the answer by changing various settings.
Rather than delete, I will answer for any who Google this later in life (unless they finally fix it).
Under your App settings, the Advanced tab has a setting called "App Type". If this is set to Native/Desktop, you will not be able to post an action.
However, Facebook's own example code from the "Get Code" button still doesn't work - which is alarming.
Actually I am trying to add items in a share point List from a windows application. It all goes fine when I added the web reference and the able to get the all the offerings listed for Lists.asmx.
When I execute my program and try to call listServiceObj.GetListAndview("Customers","");
It gives me error "The request failed with HTTP status 401: Unauthorized" . Please note that at this time my credentials and url of the service reference were;
SpListService.Lists spListService = new SpListService.Lists();
spListService.Credentials = System.Net.CredentialCache.DefaultCredentials;
spListService.Url = "http://localhost/_vti_bin/Lists.asmx";
XmlNode customerListView = spListService.GetListAndView("Customers", "");
Then I Changed the above code to ;
SpListService.Lists spListService = new SpListService.Lists();
spListService.Credentials = System.Net.CredentialCache.DefaultCredentials;
spListService.Url = "http://<PC-Name>/sites/Home/_vti_bin/Lists.asmx";
XmlNode customerListView = spListService.GetListAndView("Customers", "");
then I recieved the following error;
"Exception of type 'Microsoft.SharePoint.SoapServer.SoapServerException' was thrown."
I have made the logged in user in the group of full controll. also the member of the Administrator group.. but same result....
Also please note that when try and access "http://localhost/" or "http:///" it gives me access denied page of SP2010.... instead I have to write "http:///sites/Home/SitePages/Home.aspx" to open my team site collection
I really stuck in to this .... would be really pleased to have some solution to this problem of mine...... Thanks in advance
MJay
I had a similar problem when I implemented my first SharePoint lists Web Service client. The reason was that the autogenerated client class actually introduced itself as a Mozilla web browser by default! The SharePoint server did not allow basic authentication for browsers so the client was actually redirected to firewall login page.
I suggest you to inherit another class from the Lists class and do the following:
Set another user agent value in constructor.
Set the "preauthenticate" property to true. This should force the client to send the credentials in the first request, not only after they have been asked for.
If necessary, try giving the credentials explicitly.
See the example below.
public class CustomizedLists : Lists
{
public CustomizedLists() : base()
{
this.UserAgent = "Some SharePoint client";
this.PreAuthenticate = true;
System.Net.ICredentials creds = new System.Net.NetworkCredential("user", "pwd");
this.Credentials = creds.GetCredential(uri, "Basic");
}
}