相关疑难解决方法(0)

服务应用程序的Google oAuth 2.0(JWT令牌请求)

我正在尝试为此处描述的服务帐户实施Google oAuth 2:在UnityScript上使用https://developers.google.com/accounts/docs/OAuth2ServiceAccount(或C# - 这无关紧要,因为它们都使用相同的Mono .NET类).

我在这里找到了类似的主题:C#中是否有JSON Web Token(JWT)示例? web-token-jwt-example-in-c但我仍然没有成功.

首先,我已生成标题和声明集(就像在谷歌文档中一样)

var header: String = GetJWTHeader();
var claimset: String = GetJWTClaimSet();
Run Code Online (Sandbox Code Playgroud)

结果是(为清楚起见,用新行分隔):

{ "ALG": "RS256", "典型": "智威汤逊"}

{ "ISS": "425466719070-1dg2rebp0a8fn9l02k9ntr6u5o4a8lp2.apps.googleusercontent.com"

"范围":" https://www.googleapis.com/auth/prediction ",

"aud":" https://accounts.google.com/o/oauth2/token ",

"EXP":1340222315,

"IAT":1340218715}

Base-64编码方法:

public static function Base64Encode(b: byte[]): String {
    var s: String = Convert.ToBase64String(b);
    s = s.Replace("+", "-");
    s = s.Replace("/", "_");
    s = s.Split("="[0])[0]; // Remove any trailing '='s
    return s;
}

public static function Base64Encode(s: String): String { …
Run Code Online (Sandbox Code Playgroud)

c# oauth oauth-2.0 jwt google-oauth

15
推荐指数
1
解决办法
1万
查看次数

标签 统计

c# ×1

google-oauth ×1

jwt ×1

oauth ×1

oauth-2.0 ×1