question

Thomas Brown avatar image
Thomas Brown asked

Third Party SDK in Cloud Functions - How to store & retrieve third party API keys?

I was thinking about utilizing a third-party SDK in Cloud Scripts. I know as things stand, this isn't optimal currently as I have to include the whole SDK in the cloud script file.

My question, though, is, given my third-party SDK requires a secured API key, where would be the best place to store this API key? Does PlayFab have any sort of Environment Configuration file for storing this type of data and easily retrieving it.

I know in theory I could store the API key in let's say internal title data and whitelist the PlayFab static IP addresses but I'm not sure this is the right way to go about things.

I'm curious what recommended approach here would be given what I'm trying to do? That is execute a third party sdk from PlayFab cloud scripts with a secured API key.

CloudScript
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Sarah Zhang avatar image
Sarah Zhang answered

For your case, we would suggest you use the PlayFab CloudScript using Azure Functions. Compared to native PlayFab CloudScript, Azure Functions can support third-party SDKs better. As similar as installing the PlayFab C# all SDK to the Azure Functions projects, if the third-party SDK provides the NuGet packages, you can install packages using the dotnet add package command in the .NET Core CLI. The example command could be something like this. Please check the Azure Functions documentation -- Register Azure Functions binding extensions for more information.

dotnet add package Microsoft.Azure.WebJobs.Extensions.<BINDING_TYPE_NAME> --version <TARGET_VERSION><br>

Besides, Azure Functions also provides a feature that allows you to set up the environment variables for your function applications. You can set the app settings to manage the custom secrets, like PlayFab developer secret key, etc. This documentation Azure Functions binding expression patterns, especially this section -- Binding expressions - app settings contains an example that can help you learn about how to use app settings.

You can also refer to this thread for more information.

Best practice for storing login-information for third party sites in cloudscript - Playfab Community

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.