The Extensions documentation is no longer updated. Read the new Canva API docs here.

Decode a client secret

Learn how to convert a string into a byte array.

To calculate a request signature, an extension must decode the app's client secret into a byte array. This page demonstrates how to decode a client secret with a few different programming languages.

Go

package main
import (
b64 "encoding/base64"
"fmt"
"log"
)
func main() {
secret := "CLIENT SECRET GOES HERE"
key, error := := b64.StdEncoding.DecodeString(secret)
if error != nil {
log.Fatal(error)
}
fmt.Println(key)
}
GO

Java

import java.util.Base64;
public class Example {
public static void main(String[] args) {
String secret = "CLIENT SECRET GOES HERE";
byte[] key = Base64.getDecoder().decode(secret);
System.out.println(key);
}
}
JAVA

JavaScript

const secret = "CLIENT SECRET GOES HERE";
const key = Buffer.from(secret, "base64");
console.log(key);
JAVASCRIPT

PHP

$secret = "CLIENT SECRET GOES HERE";
$key = base64_decode($secret);
echo($key);
PHP

Python

import base64
secret = "CLIENT SECRET GOES HERE"
key = base64.b64decode(secret)
print(key)
PYTHON

Ruby

require "base64"
secret = "CLIENT SECRET GOES HERE"
key = Base64.decode64(secret)
puts key
RUBY

TypeScript

const secret = "CLIENT SECRET GOES HERE";
const key = Buffer.from(secret, "base64");
console.log(key);
JAVASCRIPT