Custom Token Settings in Smartdocs?

sidd-harth
Participant V

Hi guys,I am working on Smartdocs, I am trying to display a resource from my proxy which has an Apikey validation and hence I want to set the apikey and its value in custom token under Authentication Settings for API.

I have done it as mentioned in this doc.

http://apigee.com/docs/developer-services/content/using-smartdocs-document-apis

So ideally this custom token should be attached as an query parameter to each request.

But when I'm sending the request it again asks to Set Custom Token, check this image

custom token

Why is it asking again? What should be done?

@asagar @sudheendra1 @Maruti Chand

0 17 862
17 REPLIES 17

@Barahalikar Siddharth , What type of Authentication are you using to authenticate API Calls ? It should be one of Basic, OAuth, Custom Token . Are you using custom token based authentication ?

I am using Custom token based authentication

Dear @Barahalikar Siddharth ,

It's a feature to set Authentication once and play with APIs instead of manually setting it in query param every time you make an API call while playing with API in smartdocs. Please use popup form to set authentication instead of query param.

As explained in SmartDocs documentation, You need to send the custom token value in the popup form provided by smartdocs. The value you give in the popup will be added to Header Or Query based on your choice in the popup form.

No need to send the custom token value separately in the query param. Once you submit popup form with value, the same will be used in further calls. It's a feature in smartdocs so that you don't need to send the token value in further requests while playing with APIs.

Cheers,

Anil Sagar

Dear @asagar I'm a bit confused, I will explain what I did, according to doc I have done this,

Configuring custom token authentication

You can configure a model to use custom token authentication.

To enable custom tokens:

  1. Log in to your portal as a user with admin or content creation privileges.
  2. Select SmartDocs > Models in the Drupal administration menu.
  3. For the model you want to update, select API Revisions under Operations.
  4. For the model revision you want to edit, select Auth Settings under Operations.
  5. Expand Custom Token.
  6. For each token:
  7. Set the Token Type.
  8. Set the token Name and Value.
  9. Select Save Authentication Settings.

For each method in the model, edit the method to set its Authentication to CUSTOM.

So even after doing this as seen in the image(provided in first post) it is again asking to set custom token(i.e., apikey and value).

Ideally the apikey and value should be added by default from Operations>>Auth Settings>>Custom Token to the request right?

Dear @Barahalikar Siddharth , Let me do some research on this and get back to you.

Hi @asagar, any update on this?

Dear @Barahalikar Siddharth , Did not get a chance to look into this. @Marsh Gardiner @cesar @Chris Novak Any inputs on above issue ?

Hi @Prithpal Bhogill, any inputs on above issue?

Former Community Member
Not applicable

Not really @Barahalikar Siddharth, the only thing I can think of is whether the method has correctly persisted the authentication type as "custom" when you saved it. Can you see the custom check-box when you click on "Edit method"?

Yes @Prithpal Bhogill I can see the custom check-box when I edit the method.

Check this image screenshot-15.jpg.

One more thing about the edit method, whenever I click on edit method the parameter column gets erased. Is it normal?

Dear @Barahalikar Siddharth ,

According to recent release notes,

DEVSOL-1486SmartDocs calls can authenticate with a predefined key

Enables authentication with both pre-supplied and user-supplied API keys.

Can you please verify does it solve your use case ?

Cheers,

Anil Sagar

Thanks @Anil Sagar for remembering this issue, I have just tried this thing, it no longer asks to set custom token, but when I'm sending the request I get this error.

HTTP/1.1 401  UnauthorizedConnection: keep-aliveContent-Length: 150Content-Type: application/json{
  "fault": {
    "faultstring": "Failed to resolve API Key variable request.queryparam.apikey",
    "detail": {
      "errorcode": "steps.oauth.v2.FailedToResolveAPIKey"
    }
  }
}

I think it is still not authenticating the apikey which I provided in Operations>>Auth Settings>>Custom Token.

Can you try with new api key.. Are you sure API Key is still valid ? Are you sure you are using right policy ? Can you see trace of the API what is going on In Apigee Edge ?

Yes the API key is valid and I cannot regenerate a new api key because I'm in between of a POC.

This is the trace image,

576-api-key-trace.png

@Barahalikar Siddharth The error above ("Failed to resolve API Key variable request.queryparam.apikey") is caused when the api key is not sent as a query parameter. I usually get it when I put my API key in the headers when I should actually send it as a query parameter.

Hi @Steve Sharp, I'm sending it as an query parameter.

@Barahalikar Siddharth , Can you post request details with header and other info ?