0

I am trying to implement google server to server authentication using oAuth For that i generated credentials according to steps mentioned and them google gave me json file with below details

  // this is sample data not real data
  {
    "type": "service_account",
    "project_id": "myapp",
    "private_key_id": "17af28d89ef88g59e9c44a51csf00f894c23",
    "private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCYTyEAeQxHUP66[OTHER TEXT REMOVED]n-----END PRIVATE KEY-----\n",
    "client_email": "someemailname@projectname.iam.gserviceaccount.com",
    "client_id": "3246344567234535",
    "auth_uri": "https://accounts.google.com/o/oauth2/auth",
    "token_uri": "https://accounts.google.com/o/oauth2/token",
    "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
    "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/meshpresentations%40meshslides.iam.gserviceaccount.com"
  }

The i used "private_key" in jwt.io like shown in image below, but its showing "Invalid signature", is it because only server who provided me private key (google) can verify if its a valid token on not ? If so them when i fire a curl call i get another error.

{
   “error”: “invalid_grant”,
   “error_description”: “Invalid JWT: Token must be a short-lived token and in a reasonable timeframe”
}

What am i missing ? I am not even sure if i have made JWT token wrongly or some other problem is there. PS : i am a learner.

Image

devp
  • 23
  • 3
  • Which language are you using ? Can you show your code ? – Bertrand Martel Sep 30 '17 at 03:07
  • First, kindly check the synchronization problem with the server clock, see the [poor synchronization of the computer's clock](https://stackoverflow.com/a/36201957/5995040) answer for additional information. Second, check handling of refresh token and the old tokens. Some flows include additional steps, such as using refresh tokens to acquire new access tokens. You can also check my answer to a related [SO port](https://stackoverflow.com/a/39138741/5995040), regarding this issue. Hope this helps – Mr.Rebot Sep 30 '17 at 19:52

0 Answers0