syntax = "proto3";

package confidence.iam.v1;

import "google/api/annotations.proto";
import "google/api/field_behavior.proto";
import "confidence/auth/v1/auth.proto";

import "confidence/api/annotations.proto";

option java_package = "com.spotify.confidence.iam.v1";
option java_multiple_files = true;
option java_outer_classname = "AuthApiProto";

service AuthService {
  option (confidence.api.service_name) = "Auth";
  option (confidence.api.hosts) = "iam.eu.confidence.dev";
  option (confidence.api.hosts) = "iam.us.confidence.dev";

  rpc RequestAccessToken(RequestAccessTokenRequest) returns (AccessToken) {
    option (google.api.http) = {
      post: "/v1/oauth/token"
    };
    option (confidence.auth.v1.auth) = {
      disable_authorization: true;
    };
  }
}
message RequestAccessTokenRequest {
  //The grant type. Currently only "client_credentials" is supported
  string grant_type = 1 [(google.api.field_behavior) = REQUIRED];
  // The client id of the client to ge the token for
  string client_id = 2 [(google.api.field_behavior) = REQUIRED];
  // The secret of the client to get the token for
  string client_secret = 3 [(google.api.field_behavior) = REQUIRED];
}

message AccessToken {
  //The access token that kan be used to call the api
  string access_token = 1 [(google.api.field_behavior) = REQUIRED];
  // The ttl of the Access Token token from the time it was issued (in seconds).
  int64 expires_in = 2 [(google.api.field_behavior) = REQUIRED];
}
