Error: Generating Access Token while calling API from External Application

We have created Widget (Using Velocity) which is dynamically fetching group, forum, tags based on user selection. The widget is working fine within community.

Our requirement is to call this widget from external application.

To implement this we are generating access token using the instruction (Using the Authorization Code Grant Type) provided at the below link (community.telligent.com/.../authentication

We are getting the below error.

'community-qa.thomsonreuters.com/.../authorize from origin 'community-dev.thomsonreuters.com' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: Redirect is not allowed for a preflight request."

Any help will be appreciated.

Parents
  • You can't call or display widgets directly from an external application. You will need to build a similar UI that uses direct REST calls to get data from Community. This is actually what the Authentication training you linked is designed for - you make calls using the REST APIs and include the authentication details along with each request. 

  • Thanks   for your response.

    As you mentioned, we have built a similar UI and then calling RestApi (from external) for prefetching data on form. To access restApi, we are generating access-token (authentication details) "Using the Authorization Code Grant Type" for calling rest api with authentication from external application.

    In this process, we got the error in console while calling api.ashx/v2/oauth/authorize.

    Please help me to resolve this issue. Do let us know if you need any further information on this.

  • Make sure you follow the full instructions on that page, including setting up an OAuth client under Administration > Integration > OAuth Clients. That is where you will get the client id and secret used for authentication/authorization process. Then, the process is a two step flow to first get an authorization code, then get an access_token. These are generated from Community, you don't generate your own codes.

  • As you mentioned, the first step - When using the authorization code grant type the client application first requests an authorization code by making a request to api.ashx/v2/oauth/authorize with the following parameters in header
       response_type=code
       client_id={QAUTH_CLIENT_ID}
       redirect_uri={APPLICATION_URL}

    When call this method, got CORS error


    Access to XMLHttpRequest at 'community-qa.thomsonreuters.com/.../authorize' from origin 'null' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: Redirect is not allowed for a preflight request.

    When using the implicit grant type (with response_type=token), facing the same CORS error.

    As this is a higher priority task, please help me to resolve this issue asap.

Reply
  • As you mentioned, the first step - When using the authorization code grant type the client application first requests an authorization code by making a request to api.ashx/v2/oauth/authorize with the following parameters in header
       response_type=code
       client_id={QAUTH_CLIENT_ID}
       redirect_uri={APPLICATION_URL}

    When call this method, got CORS error


    Access to XMLHttpRequest at 'community-qa.thomsonreuters.com/.../authorize' from origin 'null' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: Redirect is not allowed for a preflight request.

    When using the implicit grant type (with response_type=token), facing the same CORS error.

    As this is a higher priority task, please help me to resolve this issue asap.

Children