OAuth Authentication and Anaplan Connect

Hi,

I have been testing OAuth connection with Anaplan Connect. And it has been quite a struggle. I started with "Authentication - Generate OAuth Token With Force Register" and it was not really working but giving strange error messages that didn't really help. After trial and error I got the example script to work by changing AuthUrl to "https://us1a.app.anaplan.com" instead of the original "https://auth.anaplan.com". Also I had to add workspace Id information to the command to get it working. Now I was able to register my client ID.

Next I moved to Authentication - Generate OAuth Token. I understood that this one should work when client id has been registered on the device so manual login wouldn't be needed. Howewer with this script I run to error pasted below:

Feign: status 500 reading AnaplanAuthenticationAPIFeign#oauthRefreshToken(String,String,String); content:
{"error":"access_denied","error_description":"Cannot read property 'startsWith' of undefined"}

This really doesn't help on identifying the problem. Any ideas on how to move forward with getting integration workint using OAuth and Anaplan Connect?

Best Answer

  • pyrypeura
    Answer ✓

    Hi @kartiendasolventoph,

    In Anaplan Connect example script AuthUrl parameter is set to “https://auth.anaplan.com”. However, this doesn’t work and you need to use “https://us1a.app.anaplan.com” as AuthUrl. Changing the value of AuthUrl should get it working.

Answers

  • Hi @pyrypeura ,

    Are you running the script in client enivironment like thier windows server with your id(not the client provided id) if so,in such case you have to add the proxyurl details in your script, then only the script will work.

    use the code like below:

    set ServiceUrl="https://api.anaplan.com"

    set AuthUrl="https://auth.anaplan.com"

    Set ProxyURL=""

    Set workspaceid=""

    set Operation=-debug -httptimeout 60 -service %ServiceUrl% -auth %AuthUrl% -via %ProxyUrl% -workspace %workspaceid%


    Hope this helps :)

    Regards,

    Venkatesh

  • Hi @Venki9902 ,

    I have been so far for testing purposes running the script from my own laptop (windows) and against our own workspace. In this case I'd assume that the proxyUrl wouldn't be the solution?

    Best regards,

    Pyry

  • Hi @pyrypeura ,

    Yes,in this case proxy is not needed.
    If possible can you share your script by removing important details.

    Regards,

    Venkatesh

  • Hi @Venki9902 , here comes couple of scripts! First one is the one with forceRegister so the one used first time to get device verified and this one is now working:

    @echo off
    rem For Windows OS : This script will store the refresh token for Oauth 2.
    rem This script should be execute only one time before Oauth 2 is used in scripts.
    rem After you run this script you will use the client id to be authenticate
    rem For details of how to configure this script visit https://help.anaplan.com/anapedia/Content/Downloads/DL_Downloads.html

    set ClientId=""
    set ServiceUrl="https://api.anaplan.com"
    set AuthUrl="https://us1a.app.anaplan.com"
    set WorkspaceId=""

    set Operation=-debug -service %ServiceUrl% -auth %AuthUrl% --forceRegister -workspace %WorkspaceId% -W

    rem *** End of settings - Do not edit below this line ***

    setlocal enableextensions enabledelayedexpansion || exit /b 1
    cd %~dp0
    if not %ClientId% == "" set Credentials=-oauth-client-id %ClientId%
    set Command=..\AnaplanClient.bat %Credentials% %Operation%
    @echo %Command%
    cmd /c %Command%
    pause

    This one is now working and I get the device verification done in similar way as in Anaplan Connect documentation.

    Next one is the one without forceRegister which is not working and error is described in the starting post.

    @echo off
    rem For Windows OS : This script will store the refresh token for Oauth 2.
    rem This script should be execute only one time before Oauth 2 is used in scripts.
    rem After you run this script you will use the client id to be authenticate
    rem For details of how to configure this script visit https://help.anaplan.com/anapedia/Content/Downloads/DL_Downloads.html

    set ClientId=""
    set ServiceUrl="https://api.anaplan.com"
    set AuthUrl="https://us1a.app.anaplan.com"
    set WorkspaceId=""

    set Operation=-debug -service %ServiceUrl% -auth %AuthUrl% -workspace %WorkspaceId% -W

    rem *** End of settings - Do not edit below this line ***

    setlocal enableextensions enabledelayedexpansion || exit /b 1
    cd %~dp0
    if not %ClientId% == "" set Credentials=-oauth-client-id %ClientId%
    set Command=..\AnaplanClient.bat %Credentials% %Operation%
    @echo %Command%
    cmd /c %Command%
    pause

  • Hello @@pyrypeura, have you solved this already? I am encountering the same error

  • Hello @pyrypeura. Did you get that working without forceRegister?

  • Hi @hmlatvanen , You will always have to start with forceRegister. As a note the logging in needs to be done in incognito mode of chrome or equivalent in other browser otherwise it won't work. After this you can run the script without forceRegister.

  • Thank you @pyrypeura that did the trick. Missed that incognito point from the manual

  • @pyrypeura if the question is answered, can you please mark the answer which helped you as the official solution! That helps others and closes the loop in the thread :)

  • BobbieLynch
    edited January 3

    It's great that you were able to make it work by changing the AuthUrl to "https://us1a.app.anaplan.com" instead of "https://auth.anaplan.commerge fruit" and adding the workspace ID information to the command.