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

1
package main
2
3
import (
4
b64 "encoding/base64"
5
"fmt"
6
"log"
7
)
8
9
func main() {
10
secret := "CLIENT SECRET GOES HERE"
11
key, error := := b64.StdEncoding.DecodeString(secret)
12
13
if error != nil {
14
log.Fatal(error)
15
}
16
17
fmt.Println(key)
18
}
Copied!

Java

1
import java.util.Base64;
2
3
public class Example {
4
public static void main(String[] args) {
5
String secret = "CLIENT SECRET GOES HERE";
6
byte[] key = Base64.getDecoder().decode(secret);
7
System.out.println(key);
8
}
9
}
Copied!

JavaScript

1
const secret = "CLIENT SECRET GOES HERE";
2
const key = Buffer.from(secret, "base64");
3
console.log(key);
Copied!

PHP

1
$secret = "CLIENT SECRET GOES HERE";
2
$key = base64_decode($secret);
3
echo($key);
Copied!

Python

1
import base64
2
secret = "CLIENT SECRET GOES HERE"
3
key = base64.b64decode(secret)
4
print(key)
Copied!

Ruby

1
require "base64"
2
secret = "CLIENT SECRET GOES HERE"
3
key = Base64.decode64(secret)
4
puts key
Copied!

TypeScript

1
const secret = "CLIENT SECRET GOES HERE";
2
const key = Buffer.from(secret, "base64");
3
console.log(key);
Copied!