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.

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
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
const secret = "CLIENT SECRET GOES HERE";
const key = Buffer.from(secret, "base64");
console.log(key);
javascript
$secret = "CLIENT SECRET GOES HERE";
$key = base64_decode($secret);
echo($key);
php
import base64
secret = "CLIENT SECRET GOES HERE"
key = base64.b64decode(secret)
print(key)
python
require "base64"
secret = "CLIENT SECRET GOES HERE"
key = Base64.decode64(secret)
puts key
ruby
const secret = "CLIENT SECRET GOES HERE";
const key = Buffer.from(secret, "base64");
console.log(key);
javascript