Genesys Cloud - Main

 View Only

Sign Up

Keep Getting Error: "We did not recognize your redirect url."

  Thread closed by the administrator, not accepting new replies.
  • 1.  Keep Getting Error: "We did not recognize your redirect url."

    Posted 04-11-2022 18:41
    No replies, thread closed.

    Hi,

    I'm new to all of this and I am currently working on my first Genesys Cloud integration. When trying to authorize my application via OAuth2, I keep getting this error screen:


    I've double and triple checked that my redirect URI is accurate down to the character. Any pointers here?

    I'm writing in Google Apps Script and here is a snippet of the code I'm working with. Thanks in advance!

    /**
     * Authorizes and makes a request to the API.
     */
    function run() {
      var service = getService();
      if (service.hasAccess()) {
        var url = 'https://apps.mypurecloud.com/api/v2/authorization/divisions';
        var response = UrlFetchApp.fetch(url, {
          headers: {
            Authorization: 'Bearer ' + service.getAccessToken()
          }
        });
        var result = JSON.parse(response.getContentText());
        Logger.log(JSON.stringify(result, null, 2));
      } else {
        var authorizationUrl = service.getAuthorizationUrl();
        Logger.log('Open the following URL and re-run the script: %s',
            authorizationUrl);
      }
    }
    
    /**
     * Reset the authorization state, so that it can be re-tested.
     */
    function reset() {
      getService().reset();
    }
    
    /**
     * Configures the service.
     */
    function getService() {
      return OAuth2.createService('Genesys')
          // Set the endpoint URLs.
          .setAuthorizationBaseUrl(
              'https://login.mypurecloud.com/oauth/authorize?client_id=<' + 
              CLIENT_ID + 
              '>&response_type=code&redirect_uri=<' + 
              REDIRECT_URI + 
              '>')
          .setTokenUrl(
              'https://apps.mypurecloud.com/oauth/token')
    
          // Set the client ID and secret.
          .setClientId(CLIENT_ID)
          .setClientSecret(CLIENT_SECRET)
    
          // Set the name of the callback function that should be invoked to
          // complete the OAuth flow.
          .setCallbackFunction('authCallback')
    
          // Set the property store where authorized tokens should be persisted.
          .setPropertyStore(PropertiesService.getUserProperties());
    }
    
    /**
     * Handles the OAuth callback.
     */
    function authCallback(request) {
      var service = getService();
      var authorized = service.handleCallback(request);
      if (authorized) {
        return HtmlService.createHtmlOutput('Success!');
      } else {
        return HtmlService.createHtmlOutput('Denied.');
      }
    }

    #Integrations

    ------------------------------
    Phillip Wright
    Shipt, Inc.
    ------------------------------