Calling API through Dev Portal linking with Edge

Not applicable

Hello,

I am having issues getting my dev portal to access my API through Edge. I believe my dev portal is correctly configured to edge and I see my proxy in the dev portal as I would expect

Here is the swagger I have used for the security section.

securityDefinitions:
  OauthSecurity:
    type: oauth2
    flow: accessCode  
    authorizationUrl: 'https://preqin-dev.apigee.net/core/connect/authorize'
    tokenUrl: 'https://preqin-dev.apigee.net/core/connect/token'
    scopes:
      myapi: My Api
security:
  - OauthSecurity:
    - myapi 


paths:


  '/{id}':
    get:
      tags:
        - Investor
        - Hedge Fund
      summary: Gets Investor by id.
      description: Return Investor by ID /investors/ No of investor (Firm ID) 
      parameters:
        - name: id
          in: path
          required: true
          description: Item id
          type: string
      security:
        - OauthSecurity:  
            - myapi
 

I can see its added OAuth to my documentation in the dev portal and when I press set I get the following screen. It does not ask me for my Client ID and Client secret which I would accept

3709-dev-portal-oauth.jpg

I can see Client ID and Client Secret under the settings menu in the dev portal where I have added some test ID/Secret

3710-dev-portal-client-id-client-secret.jpg

This isn't what I would want to do in the real world as I would want the user to provide these details but I thought it may get my dev portal to at least try to connect to my api through the edge proxy.


And when I do send the request where I would expect it to be given me the login screen it just tells me it working and I have traced my proxy and nothing happens so I don't have any idea on exactly what its doing and what its working on.

3711-dev-portal-working.jpg

I have created a client app in .NET which calls my app and works through Edge so I know my edge setup is configured correctly.

Does anybody have any idea on how I can get this working. I would be very grateful for any help somebody can give me.

Here is the Network Traffic from the Crome Developer Console if it helps

General


Request URL:http://dev-preqin.devportal.apigee.com/hedge-funds-test/apis/get/%7Bid%7D?targeturl=https%3A%2F%2Fpreqin-dev.apigee.net%2Fv1%2Finvestors%2Fhf%2F2365&_=1476348936124
Request Method:GET
Status Code:200 OK
Remote Address:23.253.180.13:80
Response Headers


Response Headers 


view source
Accept-Ranges:bytes
Age:0
Cache-Control:no-cache, must-revalidate
Connection:keep-alive
Content-Encoding:gzip
Content-Language:en
Content-Type:text/html; charset=utf-8
Date:Thu, 13 Oct 2016 08:56:19 GMT
Expires:Sun, 19 Nov 1978 05:00:00 GMT
Link:<http://dev-preqin.devportal.apigee.com/hedge-funds-test/apis/get/%7Bid%7D>; rel="canonical",<http://dev-preqin.devportal.apigee.com/node/78>; rel="shortlink"
Server:nginx
Transfer-Encoding:chunked
Vary:Accept-Encoding, Cookie
Via:1.1 varnish-v4
X-Content-Type-Options:nosniff
X-Frame-Options:SAMEORIGIN
X-Generator:Drupal 7 (http://drupal.org)
X-Pantheon-Endpoint:3db4461c-35c8-4170-a7e9-0cd338f4b329
X-Pantheon-Styx-Hostname:styx480365c9
X-Styx-Req-Id:styx-60e941cb88750496a4a01c3b07383650
X-Styx-Version:StyxGo
X-Varnish:83929525
xkey:


Requet Heasders 


Request Headers
view source
Accept:*/*
Accept-Encoding:gzip, deflate, sdch
Accept-Language:en-GB,en-US;q=0.8,en;q=0.6
Connection:keep-alive
Content-Type:
Cookie:_hp2_id.429197800=%7B%22userId%22%3A%224104977109584089%22%2C%22pageviewId%22%3A%224455358141274107%22%2C%22sessionId%22%3A%223314827891310203%22%2C%22identity%22%3Anull%2C%22trackerVersion%22%3A%223.0%22%7D; colodin_thank_you_page_referrer=; colodin_thank_you_page_url=http%3A%2F%2Fapigee.com%2Fabout%2Fsupport%2Fportal; colodin_id=1113318258-1252510241-3748215214-apigee.com; __ar_v4=%7CWOIUCZVQNZCNDGIAV2SRXE%3A20161011%3A1%7CTHDP466U6BBCDHZGGN2MOM%3A20161011%3A1%7CH5E7JF3L6FEQ3IVR3ENNVS%3A20161011%3A1; SESS8ab5b4373ab32eed028986f4a3787f71=86RjzYfKzk-ZTf3hNV78iJcSo0FAmxySv6Bj7DTmbEg; Drupal.tableDrag.showWeight=0; _ga=GA1.2.72260411.1476275709; _vwo_uuid_v2=3EEC1F8238282D92E8758D49BEAE11F0|c758a16439559f48fed638fba200e9d0; __utma=191941370.72260411.1476275709.1476287062.1476296122.4; __utmc=191941370; __utmz=191941370.1476296122.4.3.utmcsr=google|utmccn=(organic)|utmcmd=organic|utmctr=(not%20provided); _mkto_trk=id:351-WXY-166&token:_mch-apigee.com-1476275709032-30892; has_js=1
Host:dev-preqin.devportal.apigee.com
Referer:http://dev-preqin.devportal.apigee.com/hedge-funds-test/apis/get/%7Bid%7D
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36
X-Requested-With:XMLHttpRequest
Query String Parameters
view source
view URL encoded


Query String Parameters 


targeturl:https://preqin-dev.apigee.net/v1/investors/hf/2365
_:1476348936124

And here is the error which is happening in my console

VM96:1 Uncaught SyntaxError: Unexpected token < in JSON at position 0
	n.parseJSON @ jquery.js:7522
	e.parseJSON @ jquery-migrate.min.js?v=1.2.1:2
	renderRequest @ model.js?oexpu1:1257
	success @ model.js?oexpu1:143
	j @ jquery.js:3099
	fireWith @ jquery.js:3211
	x @ jquery.js:8264
	(anonymous function) @ jquery.js:8605

Thank you in advance

Solved Solved
1 39 1,719
1 ACCEPTED SOLUTION

@Daniel Barnes ,

Thank you for highlighting this issue. It's a bug / It's yet to be resolved in developer portal. Please find the root cause behind above issue.

  • Smartdocs makes API call to Apigee Smartdocs proxy which in turn makes API call to the actual proxy.
  • By default, the Apigee Smartdocs proxy URL is "https://apiconsole-prod.apigee.net/smartdocs/v1/sendrequest".
  • We have a setting in portal admin screen, where it can be updated. It's useful for OnPremises developer portal to point to Apigee Installation of onPremise Edge.
  • When someone updates other settings in "admin/config/smartdocs", this value is set to empty. Ideally, it should not change default URL "https://apiconsole-prod.apigee.net/smartdocs/v1/sendrequest"
  • Due to the empty value, When send request button is hit, It makes a call to same URL of the browser, which results in portal page HTML response & console errors.
  • It worked for me when i created new portal with latest version, because, same has not been overridden using "admin/config/smartdocs". I thought issue was fixed in recent release. Actually, It's not.

In your portal, I have manually updated the proxy URL to, "https://apiconsole-prod.apigee.net/smartdocs/v1/sendrequest". Smartdocs should work now. Also, We have resolved code conflict issues in your instance.

Hope it helps. Keep us posted if any. If your query above is resolved, Please accept answer so that it will be helpful for others too.

View solution in original post

39 REPLIES 39

Me too, Same issue with smartdocs. I believe something has been changed in model.js recently & smartdocs "Try API" option is broken.

@Daniel Johnson , @Chris Novak , @Marsh Gardiner FYI

There is a recent release of developer portal, can you please update to the latest & try out same. Similar issues got fixed after i updated the portal to latest release. Do take backup of instance before you update the portal to latest.

Hello Anil, Thank for the answer to this. How do I update the developer portal?

@Daniel Barnes , Are you oncloud / opdk ?

I am in the cloud.

@Daniel Barnes , If you have pantheon access, you can update using pantheon dashboard. Pantheon is the cloud hosting platform for Apigee Developer Portal. Let me know if you want me to update to latest, i can do same.

it would be great if you could try and do it for me as I am hitting issues.

If I try and apply update I get the following error

CONFLICT (content): Merge conflict in profiles/apigee/themes/apigee_responsive/template.php CONFLICT (modify/delete): CHANGELOG.txt deleted in HEAD and modified in 93528e7833d0133d8d3cacbe7fbefdde1db8ef67. Version 93528e7833d0133d8d3cacbe7fbefdde1db8ef67 of CHANGELOG.txt left in tree.

I then try and resolve conflicts and get this error

We were not able to perform the merge safely. See the Applying Upstream Updates doc for further debugging tips.

Anil, I certainly haven't changed anything but Pronovix did the development for the dev portal.

@Daniel Barnes ,

Thank you for highlighting this issue. It's a bug / It's yet to be resolved in developer portal. Please find the root cause behind above issue.

  • Smartdocs makes API call to Apigee Smartdocs proxy which in turn makes API call to the actual proxy.
  • By default, the Apigee Smartdocs proxy URL is "https://apiconsole-prod.apigee.net/smartdocs/v1/sendrequest".
  • We have a setting in portal admin screen, where it can be updated. It's useful for OnPremises developer portal to point to Apigee Installation of onPremise Edge.
  • When someone updates other settings in "admin/config/smartdocs", this value is set to empty. Ideally, it should not change default URL "https://apiconsole-prod.apigee.net/smartdocs/v1/sendrequest"
  • Due to the empty value, When send request button is hit, It makes a call to same URL of the browser, which results in portal page HTML response & console errors.
  • It worked for me when i created new portal with latest version, because, same has not been overridden using "admin/config/smartdocs". I thought issue was fixed in recent release. Actually, It's not.

In your portal, I have manually updated the proxy URL to, "https://apiconsole-prod.apigee.net/smartdocs/v1/sendrequest". Smartdocs should work now. Also, We have resolved code conflict issues in your instance.

Hope it helps. Keep us posted if any. If your query above is resolved, Please accept answer so that it will be helpful for others too.

Hello Anil, Thank you very much for this. Its good to get a response from the dev portal.

It is not authorising my call though using OAuth and I get the following error

HTTP/1.1 400 Bad RequestConnection:keep-aliveContent-Length:110Content-Type:application/jsonDate:Thu, 13 Oct 2016 12:31:00 GMTServer:Apigee RouterWWW-Authenticate:Bearer realm="null"{
  "message": "access token is invalid",
  "info": "https://developers.preqin.com/errors"
}

As I have said above I would expect it to ask me for my client ID and client Secret and then send me to my OAuth end point https://preqin-dev.apigee.net/core/connect/authorize to Authorize

Here is my YAML code for OAuth

securityDefinitions:
  OauthSecurity:
    type: oauth2
    flow: accessCode  
    authorizationUrl: 'https://preqin-dev.apigee.net/core/connect/authorize'
    tokenUrl: 'https://preqin-dev.apigee.net/core/connect/token'
    scopes:
      myapi: My Api
security:
  - OauthSecurity:
    - myapi 

Is this something you would be able to help with me.

Thanks so much

Daniel.

@Daniel Barnes , Glad to know part of your query is resolved.

Regarding OAuth, Which OAuth grant type are you using ?

Authorization code grant

Hello Anil

Did you have any further response on this.

I would really like to resolve this issue today if at all possible.

Thanks,

Daniel

@Daniel Barnes

Stay tuned , I will keep you posted. Unfortunately, No ETA, I need to explore this feature in smartdocs & find out what exactly is causing issue.

Hello @Anil Sagar

Thank you very much for the update, as I really need to get this resolved asap as we want to show the dev portal to some clients as soon as possible I have spent some time looking at this today and seeing if I can work it out unfortunately I cannot but I may have some further information to help you.

I have been changing the Advanced Settings under the Edit Security Scheme as shown below

3731-edit-security-section-advanced-settings.jpg

But am not really getting anywhere. I have noticed that if I set the OAuth 2.0 setting on my dev portal and look in the console on the chrome dev tools I do get the authorize string created which I expect but the dev portal is not actually doing anything with the string. It just seems to be printing it in the console as shown below.

3732-dev-portal-console-window.jpg

If I click on the screen I get the Identity Login Screen as I would expect if it was working correctly and I can log my details in and I am then return to the redirect string. This isn't into my dev portal though as shown below and you will notice I do have the auhorization code

3733-redirect-string.jpg

I hope this further information helps you and if you need anything else from me please do not hesitate to contact me.


Thanks,

Daniel

Thank you @Daniel Barnes for more details. Inconvenience is regretted.

I will spend some time tomorrow & will give you update by EOD, Sunday IST. I will keep you posted.

Hello @Anil Sagar, Thank you so very much for that. Daniel

@Daniel Barnes ,

I do see a popup to login & consent screen errors out. I think you need to fix few things on your application side. Please see screencast attached below.

3734-ezgifcom-video-to-gif.gif

Keep us posted if any.

Hello @Anil Sagar

I do not see the popup you are seeing when I press the set OK button. I just see in the console window the link it should be calling as I have described above. Why would that be?

Thanks

Daniel

Thank you so very much @Anil Sagar.

I am getting closure and closure now. I now have the Identity Popup working and I am able to type the username and password and I get redirected back to a new window with my first Oauth code but I do not have my access code as shown below

3735-oauth-code.jpg

I now just need to get it to do the final leg of the OAuth flow.

Hello @Anil Sagar

I have spent some time now looking at the apigee documentation / community and I cannot find anything to point me in the right direction.

I would assume that having the OAuth flow as part of the setup within the dev portal the dev portal would manage the whole oauth flow for me so I am assuming I just haven't configured something correctly but documentation seems quite limited on this unless I am just looking in the wrong place.

Any help/advice would be greatly appreaited.

Thanks

Daniel.

@Daniel Barnes

It's still same error for me, I don't see any login screen with username / password. How can i reproduce the issue you are seeing ?

Hello @Anil Sagar

I don't actually know why you would be getting an error message,

Are you using the right item in the documentation. Its this one http://dev-preqin.devportal.apigee.com/hedge-fund-investors/apis/get/%7Bid%7D

Could it be something to do with the user you are logged into the dev portal with. I am doing it with the Administrator user.

It is worth us doing a GoTo Meeting so I can show you exactly what I am doing?

@Daniel Barnes , I was using some other smartdoc, I see the login screen now, Can you send me the sample credentials to login ? Use "Ask An Expert" button on right side to send the credentials.

@Daniel Barnes , I see an error, I think access code generation is successful, Access code negotiation is failed. Inspect element on console to see error. It is something to do with access token settings in developer portal. Stay tuned, We are close to solve the problem.

3736-screen-shot-2016-10-16-at-35912-pm.png

@Daniel Barnes ,

Looks like below setting is the issue,

3737-error.png

Thank you, I have sent details

Yes I must admit I put that in not knowing what it should be. Should that be "AccessToken"

Or access_token?

@Daniel Barnes , Yes, I have updated to "access_token", It's working now. Please confirm.

Hello @Anil Sagar You really are a star and we are so close now.

The way that was working is it was passing the authorization code in a query string so wasn't returning data as we need to get it in the header as you can see in the following JMeter test request

3738-jmeter-test.jpg

But it looks like it should be passing it through as header as it is setup correctly or I think it is as below

3739-setting-as-header.jpg

I am getting an Invalid access token

3740-invalid-access-token.jpg

And you can see here its setting the Access Token in the query string

3742-curl-access-token.jpg

Thank you so much

Daniel

@Daniel Barnes , Stay tuned, investigating same. Ideally, below setting should be header.

3743-screen-shot-2016-10-16-at-42807-pm.png

I changed same, Changes are not reflected. It still sends in query param. Investigating same.

@Daniel Barnes , Changed above setting & Seems like some kind of cache prevented picking up above setting for a while.

Everything should be fine now, At last 200 OK 🙂

3745-screen-shot-2016-10-16-at-45428-pm.png

Hello @Anil Sagar

That is amazing. It looks brilliant. Thank you so very much for helping me with this. I am so very happy right now.

Do you know how I can get this code out as the swagger code or is that not possible?

Daniel.

Awesome @Daniel Barnes , Glad issue is resolved. I believe you can now accept this answer & Also upvote same 😉

Can you please clarify what do to you mean "Do you know how I can get this code out as the swagger code or is that not possible?" Please create a new question with more details for better visibility.

I have voted but not sure how to accept the answered but I will work it out.

Its not important at the moment but I would like to update my original swagger script so it includes all the changes we have made and didn't know if there was a feature to export as swagger or something similar.

At the moment I am just so happy its all working.

Daniel

@Daniel Barnes ,

When you upload swagger / open api spec, it is stored in Apigee API Modelling datastore as another spec called "smartdocs json". You can only export changes in this spec. If you need swagger / open api spec, you have to do these changes manually offline. Find more about same here.

Regarding how to vote / accept resolved answer, see screenshot below,

3746-vote.png

Hello @Anil Sagar, Thank you very much for this and all the support you have given me the last couple of days it really is very much appriated. Daneil

Anytime @Daniel Barnes , Also, Thank you, for highlighting above issue. We understand, Smartdocs is little complex to configure as of today. Questions like above will help others in the community. Keep us posted moving forward.