// Copyright 2022 LTN Global Communications, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. syntax = "proto3"; package tv.make.api; import "auth/token/token.proto"; import "protoc-gen-openapiv2/options/annotations.proto"; import "google/api/annotations.proto"; import "google/protobuf/empty.proto"; option go_package = "git.ltnglobal.com/make.tv/genproto/api;api"; service TokenService { // Create a new access token for a given username and password. // // Does not require the token to be in the request context. rpc CreateToken(CreateTokenRequest) returns (CreateTokenResponse) { option (google.api.http) = { post: "/v1/auth/tokens" body: "*" }; option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { security: {} }; } // Delete a given access token. Returns NOT_FOUND if no such token exists. // // Does not require the token to be in the request context. rpc DeleteToken(DeleteTokenRequest) returns (google.protobuf.Empty) { option (google.api.http) = { delete: "/v1/auth/tokens/{token.access_token}" }; option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { security: {} }; } // Gets the current user for this access token. // // Does not require the token to be in the request context. rpc GetCurrentUser(GetCurrentUserRequest) returns (GetCurrentUserResponse) { option (google.api.http) = { get: "/v1/auth/tokens/{token.access_token}:getCurrentUser" }; option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { security: {} }; } } // Request message for TokenService.CreateToken. // // Does not require an access token to be present // as metadata. message CreateTokenRequest { // The name of the user or e-mail to login. string username = 1; // The password of the user. string password = 2; } // Response message for TokenService.CreateToken. message CreateTokenResponse { // The newly generated token Token token = 1; } // Request message for TokenService.DeleteToken. // // Does not require an access token to be present // as metadata. message DeleteTokenRequest { // The token to delete. The access token MUST be present. // All other attributes are optional. Token token = 1; } // Request message for TokenService.GetCurrentUser. message GetCurrentUserRequest { // Token for which to request the current user. Token token = 1; } // Response message for TokenService.GetCurrentUser. message GetCurrentUserResponse { // The id of the user for the given token. string user_id = 1; }