How to drive the saggerhub api
Hi. It appears that I should be able to use swaggerhub to pull data from my WA database with the API, but I can't figure out how to do this because the code in the code window of swagger is 'read only'. I can see that I have to change it so that it points to my WA site, and although I have an option to enter API key to authenticate, there seems no way to change the site. Help appreciated
-
Webmaster commented
Dmitry: I have managed to register for and get Postman to download the non admin swagger api definition.. but how do you set up Postman to actually use the api. E.g. get the authenticartion to work?! Could you provide some guidance on that - that would be greatly appreciated!
Also tested the API browser and that works.. did not of that, so playing around with that a bit.. would be great to check out Postman and get that going as well..
.. and oh, last bit.. the admin api on swagger does not want to download by rest resolved. Anyt thoughts as to why it is giving this error: "Error.Cannot parse invalid API definition, please fix any syntax issues."
-
Yes, you can, it should work.
I can't say something about dangerous content, not enough information. Anyway these errors not from API or API browser.
-
Anonymous commented
Can the API Browser be used with the membership API? If so, how? I just get errors of potentially dangerous content.
-
Stu commented
Hi Dmitry,
I did try the OAuth with password method too, but just to be sure I tried again. Firstly, I assume I use pwd/user of an admin of the WA site (I've tried two valid admin details). I added clientID and secret that I know to work already. Continually get a popup asking for user/pwd.I then tried with asking for "type: basic auth" which only needs user/pwd and I find out that my admin users are seen as invalid: "auth errorError: Unauthorized, error: invalid_client" so I'm not able to pass the Auth stage with those user details.
Finally I tried OAuth with clientCredentials, using clientId and secret that I am already able to pull data with in my actual app. I get error: "auth errorError: Bad Request, error: unauthorized_client, description: Client is not authorized to use this grant type."What in fact is the 'client' in this case? Is it the WA account? Or is it something to do with how swaggerhub attempts to validate? It seems the problem is in this (unless I totally have overlooked something)
-
Stu,
Looks like you use "OAuth2, accessCode" mode to access api. This mode is described in swagger specification, but is it not possible to use it from SwaggerHub interface. I recommend to use "OAuth2, password" or "OAuth2, application" mode from SwaggerHub interface.
I changed order of authorization modes, so that "OAuth2, password" will be the first in the list. Please give it a try and let me know if something goes wrong.
-
Stu commented
Thanks Dmitry, this is where I am having the problems - when I use the auth button, it asks for client ID and secret only. I enter valid data for these and select scope, click 'authorise' and a new page opens to:
https://your_organization.wildapricot.org/sys/login/OAuthLogin?response_type=code&client_id=qvesob9xud&redirect_uri=https%3A%2F%2Fapp.swaggerhub.com%2Foauth2_redirect&scope=auto&state=VHVlIE5vdiAyMCAyMDE4IDE2OjIyOjExIEdNVCsxMzAwIChOZXcgWmVhbGFuZCBEYXlsaWdodCBUaW1lKQ%3D%3DObviously this fails (with "website not found" because it is pointing to "your_organisation" but it is not clear how I can change this. That is why I mentioned that the API was read-only. Is there another way to point this authentication to the actual client site?
-
p.timothy commented
Have the same issue. To get around this, I used the C# sample program on https://github.com/WildApricot/ApiSamples and prevailed upon it to get my data.