0

I am working on FreshDesk based client apps,

Facts and my problem:

  1. FreshDesk widgets/apps only allow jQuery/JS and HTML, doesn't give any server side support yet for developers.
  2. I am looking get list of Power BI reports in the widget.
  3. This requires Azure AD Oauth Token, thus I am having trouble making a CORS request.

I some how asked freshdesk to whitelist the domains required for microsoft domain's oauth request calls.

I still get the following error

XMLHttpRequest cannot load https://login.microsoftonline.com/common/oauth2/authorize?. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://xxxx.freshdesk.com' is therefore not allowed access.

My code is as below

jQuery.ajax({ 
    type: 'GET', 
    url: authorizeURL,
    headers: headers1,
    beforeSend: function(xhr){xhr.setRequestHeader('Access-Control-Allow-Origin','https://login.microsoftonline.com');},
    success : function(text1)
              {console.log(text1);}         
            });
codester
  • 56
  • 1
  • 6

1 Answers1

0

Freshdesk now supports OAuth in a different way.

Provide the following in OAuth_config.yaml

client_id:      "5eXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXc8d1"
client_secret:  "q8NbXXXXXXXXXXXXXXXX1p1" 
Authorize_url:  "https://login.domain.com/authorize"
token_url:      "https://login.domain.com/token"
options:
  scope:        "read"
  token_type:     "account"

More information available at https://developers.freshdesk.com/docs/oauth/

codester
  • 56
  • 1
  • 6