小编use*_*358的帖子

在服务器端验证令牌时获得无效的授权,格式错误的身份验证代码

我们正在尝试在我们的产品中使用 Google OAuth。流程是让客户端从用户那里获得身份验证并将令牌发送到服务器。在服务器端,我需要验证令牌是否有效。目前,我使用 Google 提供的 OAuth2Sample 作为客户端。当我在服务器端验证发送的令牌时,出现以下异常:

com.google.api.client.auth.oauth2.TokenResponseException: 400 错误请求

{
“错误”:“invalid_grant”,
“error_description”:“格式错误的验证码。”
}

在 com.google.api.client.auth.oauth2.TokenResponseException.from(TokenResponseException.java:105)

在 com.google.api.client.auth.oauth2.TokenRequest.executeUnparsed(TokenRequest.java:287) 在 com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeTokenRequest.execute(GoogleAuthorizationCodeTokenRequest.java:158)

这是服务器端的代码:

GoogleTokenResponse tokenResponse =
              new GoogleAuthorizationCodeTokenRequest(
                  new NetHttpTransport(),
                  JacksonFactory.getDefaultInstance(),
                  "https://www.googleapis.com/oauth2/v4/token",

                  CLIENT_ID,
                  CLIENT_SECRET,

                  authToken, //Sent from the client
                  "")  // specify an empty string if you do not have redirect URL
                  .execute();
Run Code Online (Sandbox Code Playgroud)

这是我在客户端获取访问令牌的方法:

private static final List<String> SCOPES = Arrays.asList(
"https://www.googleapis.com/auth/userinfo.profile",
"https://www.googleapis.com/auth/userinfo.email");
//...

GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder(
        httpTransport, JSON_FACTORY, 
clientSecrets, //Client ID and Client Secret
SCOPES).setDataStoreFactory(
        dataStoreFactory).build();

LocalServerReceiver lsr = …
Run Code Online (Sandbox Code Playgroud)

java google-oauth

9
推荐指数
1
解决办法
5606
查看次数

如何将Apple Watch的传感器数据传输到iPhone?

有没有办法从Apple Watch获取传感器数据?例如,如何从Apple Watch连接并获取心率到我的应用程序?这些是我在我的应用中需要执行的步骤:

  1. 定义代表以从Apple Watch接收心率信息.
  2. 向Apple Watch请求定期发送数据

我知道它如何适用于BT上的其他HR监视器.界面是否类似?或者应该依靠HealthKit来实现这一目标?

ios healthkit watchkit

8
推荐指数
1
解决办法
3801
查看次数

使用Webpack时出错

我正在尝试按照本教程学习webpack .

当我跑下午开始时,我得到70个错误,如下所示.

$ npm start

> angular2-webpack@1.0.0 start /Users/angular-webpak

[at-loader] Using typescript@2.0.10 from typescript and "tsconfig.json" from /Users/angular-webpak/src/tsconfig.json.

[at-loader] Checking finished with 70 errors
...

ERROR in [at-loader] node_modules/@types/jasmine/index.d.ts:39:52 
    TS1005: '=' expected.
ERROR in [at-loader] node_modules/@angular/common/src/directives/ng_class.d.ts:48:34 
    TS2304: Cannot find name 'Set'.
ERROR in [at-loader] node_modules/@angular/common/src/pipes/async_pipe.d.ts:44:38 
    TS2304: Cannot find name 'Promise'.
ERROR in [at-loader] node_modules/@angular/compiler/src/aot/compiler.d.ts:32:38 
    TS2304: Cannot find name 'Promise'.
ERROR in [at-loader] node_modules/@angular/compiler/src/aot/compiler.d.ts:44:32 
    TS2304: Cannot find name 'Map'.
ERROR in [at-loader] node_modules/@angular/compiler/src/aot/compiler_host.d.ts:20:33 
    TS2304: Cannot find name 'Promise'. …
Run Code Online (Sandbox Code Playgroud)

webpack angular

7
推荐指数
1
解决办法
6514
查看次数

eks create cluster 命令失败并显示错误:在输入字节 11 处计算指纹非法 base64 数据

我正在尝试使用 EKS 创建一个 kubernetes 集群。我正在使用的命令是

eksctl create cluster --name prod --version 1.14 --region us-west-2 --nodegroup-name standard-workers --node-type t3.medium --nodes 3 --nodes-min 1 --nodes-max 4 --ssh-access --ssh-public-key <pathto>/certificate.pem --managed
Run Code Online (Sandbox Code Playgroud)

上面的 certificate.pem 是我从 AWS 控制台“我的安全凭证”页面下载的 x.509 证书。该命令引发错误:

Error: computing fingerprint for key "/Users/xxxx/work/tech/aws/certificate.pem": error decoding SSH public key: "-----BEGIN CERTIFICATE-----\nMIIDhjCCAm6gAwIBAgIVAKuhOc5Vbrgl7Y3ZfxBAj9uY9aeDMA0GCSqGSIb3DQEB\nBQUAMFMxITAfBgNVBAMMGEFXUyBM
Run Code Online (Sandbox Code Playgroud) -----END CERTIFICATE-----\n" 错误:输入字节 11 处的 base64 数据非法

essh-public-key eksctl 在这里期待什么?

amazon-web-services amazon-eks eksctl

3
推荐指数
1
解决办法
993
查看次数