Links

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)
}

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);
}
}

JavaScript

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

PHP

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

Python

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

Ruby

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

TypeScript

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