Using different environments

We have created a test environment for the purpose of testing some code using the  API.   What we cannot figure out is how to connect a specific developer app to the test environment.  


I originally created an app that has a client ID and Secret that works with the live environment.   After the test environment was created, I find I can use the web page tools to try different API endpoints and we I get the dropdown on the authorization screen to select between environment 1 and environment 2.  So far so good.


But when I try to specify the test environment 2 from outside using a python script, I can't find the trigger to point to environment 2.   


I created a second app with a different ID and Secret, and it works - but I doesn't seem to be able to point specifically to the second environment.    Just generically to the subscription with a different key.   I've scoured this developer site for more details, but no luck.


Can anyone explain the process?   All kinds of keys and auth codes but nothing I can see connects an app to a specific test environment.  Do we need another subscription?   Maybe that's it.

 

Comments

  • Hi Dan,


    The environment (i.e., the logical database that will be accessed by any given API call) is actually burned into the access token itself.  Your application can access any environment in which it has been enabled (via the Control Panel -> Applications page) by using the access token associated with that environment.  You shouldn't need to define 2 applications (unless you really need 2 applications) - your single application can access data in either of your environments (assuming the app has been enabled within both environments, and you've obtained an access token for each environment).  


    Your SKY API subscription key isn't tied to any particular environment - it's tied to your developer account and just represents you as a developer.


    Looking at our internal systems, I can see that you've defined two SKY applications, one has been enabled in your "Environment 1", and the other has been enabled in your "Environment 2". The SKY API Console app has been enabled in both of your environments, which explains why you're able to select between either environment on the OAuth consent form.  Your first app has obtained access tokens for environment 1, but none for environment 2.


    So the key for you is just using the right access token from within your app/script - that will control which of your environments is being accessed.  And in order for your first app to get an access token for Environment 2, you'll need to get it enabled within that environment via the Control Panel -> Applications page.  If you do not see that page on the menu when you log into Environment 2, it means you aren't an admin within the environment.


    Looking at your user permissions, I can see that you're an admin for Environment 1 but not Environment 2.  Given that it sounds like you intend for Environment 2 to be a "test" environment, I think you just need to work with your administrator to either get your app enabled in environment 2, or get admin access within environment 2 so you can enable your app.


    I hope this helps - please let us know if you have any questions!

     
  • It sounds to me like access to the applications page is what I am missing.


    IF I follow, I have one subscription which is good for either environment.  That makes sense.


    You indicate I should only need one app that will have a single application ID and secret key, which should be good for either environment. 


    So I think you are saying I should be able to enable or disable the access to either environment for app 1 from the applications page, which will then determine the target database and return the appropriate tokens accordingly.


    For context, my code gets the initial authorization calling the auth URL using the ID of the app, the secret and the callback url.   I am storing the authorization tokens in a cache so that I don't have to repeat the initial authorization unless things are dormant for some time.  After that there is a routine to refresh the tokens that also uses the ID of the app and the secret key of the app. 


    I don't see anything else in the authorization steps that specify which environment is getting called and returning me a unique token for that environment. 


    It seems to me the switch has to have something to do with the app and/or which environment it is enabled for.  Still trying to get my access to the applications page configured.




     
  • Hi Dan,


    Yes - you are correct, you need to get access to the Control Panel -> Applications page for your "test" environment.  That page is (currently) only accessible by environment admins.  You are listed as an environment admin for your "Environment 1" environment, but not your "Environment 2" environment.  So that menu option won't be available.


    As an admin for your organization, you should be able to manage environment admins within the "Admin" area (found under the hamburger dropdown menu in the upper left area of the page).


    Once you get access to the Applications page for your Environment 2, you can enable your SKY application (via the "Add application" button, and pasting in the ID of your application). This will result in both environments appearing on the OAuth consent form, which will allow you to pick which environment you want to target.  The resulting access token emitted by that process will control which environment is accessed by API calls.  


    FWIW, we do provide some details about the selected environment with the /token endpoint response, documented here:
    https://developer.blackbaud.com/skyapi/docs/authorization/auth-code-flow/tutorial#tokens-returned
  • I don't know what else to do on my end. 
     Everything I need seems to be behind a wall so I'm taking
    shots in the dark.  



    On Thu, Feb 20, 2020 at 9:02 AM
    Ben Lambert via Blackbaud Community <community@blackbaud.com>
    wrote:



    mySWL
    InstantAlert
    Hi
    Dan!

    Please do not reply to this email.
    Respond in Community via the links below.

    Hi Dan,


    Yes - you are correct, you need to get access to the Control Panel
    -> Applications page for your "test" environment.  That
    page is (currently) only accessible by environment admins.
     You are listed as an environment admin for your "Environment
    1" environment, but not your "Environment 2" environment.  So
    that menu option won't be available.


    As an admin for your organization, you should be able to manage
    environment admins within the "Admin" area (found under the
    hamburger dropdown menu in the upper left area of the page).


    Once you get access to the Applications page for your Environment
    2, you can enable your SKY application (via the "Add application"
    button, and pasting in the ID of your application). This will
    result in both environments appearing on the OAuth consent form,
    which will allow you to pick which environment you want to target.
     The resulting access token emitted by that process will
    control which environment is accessed by API calls.  


    FWIW, we do provide some details about the selected environment
    with the /token endpoint response, documented here:
    https://developer.blackbaud.com/skyapi/docs/authorization/auth-code-flow/tutorial#tokens-returned

     
    Reply ByEmail
     


      



    Unsubscribe from this topic
    START New Topic



    Email
    Blackbaud icon
    |

    800.443.9441



    |



    Twitter icon
    We care
    about your privacy. You are receiving this notification to
    facilitate your use as a member. If you don't want to receive
    alerts like this to your external email account in the future, you
    can change your Privacy settings under the 'My Account' section of
    your community profile.


    Is this email going to your junk mail folder? Add community@blackbaud.com to your address book or
    safe senders list to ensure that you receive all future alerts in
    your inbox.

    To manage your
    notifications settings, click here: Notification Settings. To unsubscribe
    permanently from all site updates, click here: Unsubscribe







    --



    Dan Sullivan
    Analyst/Programmer

    262-551-6654




  • I got access (not sure what was changed) to the apps from within the RE NXT interface and was able to check to see what was there.  Looks like everything was set up OK.


    The missing piece for me seems to be that it is not enough to replace the client ID and secret to switch between the environments.   I had coded the initial authorization as a separate script, so that once authorized, the refreshing of tokens is all that is needed for however many weeks.  Theoretically that initial auth script might never have to be rerun if the refresh process is active, but I guess it does have to be run the first time to sync up to the second environment.  My code was trying to refresh an authorization that had not yet been granted.  


    I assume when I want to switch back to Environment 1 I will need to rerun the initial authorization script to get Environment 1 back in focus and then the client ID and secret for the live system will sync everything up.


    I also was getting an error on the callback URL, which I corrected within the app.  






     

Categories