mirror of
https://github.com/bitwarden/android.git
synced 2024-12-18 23:31:52 +03:00
switch to google creds
This commit is contained in:
parent
db04d6e642
commit
08299902e3
1 changed files with 18 additions and 17 deletions
|
@ -5,6 +5,7 @@ using Google.Apis.Services;
|
|||
using System.Collections.Generic;
|
||||
using Google.Apis.AndroidPublisher.v2.Data;
|
||||
using System.IO;
|
||||
using Google.Apis.Auth.OAuth2;
|
||||
|
||||
namespace Bit.Publisher
|
||||
{
|
||||
|
@ -13,7 +14,7 @@ namespace Bit.Publisher
|
|||
private const string Package = "com.x8bit.bitwarden";
|
||||
|
||||
private static string _apkFilePath;
|
||||
private static string _apiKey;
|
||||
private static string _credsFilePath;
|
||||
private static EditsResource.TracksResource.UpdateRequest.TrackEnum _track;
|
||||
|
||||
static void Main(string[] args)
|
||||
|
@ -25,7 +26,7 @@ namespace Bit.Publisher
|
|||
|
||||
try
|
||||
{
|
||||
_apiKey = args[0];
|
||||
_credsFilePath = args[0];
|
||||
_apkFilePath = args[1];
|
||||
|
||||
var track = args[2].Substring(0, 1).ToLower();
|
||||
|
@ -55,33 +56,37 @@ namespace Bit.Publisher
|
|||
Console.WriteLine("ERROR: " + e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
Console.ReadLine();
|
||||
}
|
||||
|
||||
private async Task Run()
|
||||
{
|
||||
GoogleCredential creds;
|
||||
using(var stream = new FileStream(_credsFilePath, FileMode.Open))
|
||||
{
|
||||
creds = GoogleCredential.FromStream(stream).CreateScoped(AndroidPublisherService.Scope.Androidpublisher);
|
||||
}
|
||||
|
||||
var service = new AndroidPublisherService(new BaseClientService.Initializer
|
||||
{
|
||||
ApplicationName = "appveyor",
|
||||
ApiKey = _apiKey,
|
||||
HttpClientInitializer = creds
|
||||
});
|
||||
|
||||
var editsRequest = new EditsResource.InsertRequest(
|
||||
service,
|
||||
null,
|
||||
Package);
|
||||
var edit = await editsRequest.ExecuteAsync();
|
||||
var editRequest = service.Edits.Insert(null, Package);
|
||||
var edit = await editRequest.ExecuteAsync();
|
||||
|
||||
Console.WriteLine("Created edit with id {0}.", edit.Id);
|
||||
|
||||
Apk apk = null;
|
||||
var apkResource = new EditsResource.ApksResource(service);
|
||||
using(var stream = new FileStream(_apkFilePath, FileMode.Open))
|
||||
{
|
||||
var uploadMedia = apkResource.Upload(
|
||||
var uploadMedia = service.Edits.Apks.Upload(
|
||||
Package,
|
||||
edit.Id,
|
||||
stream,
|
||||
"application/vnd.android.package-archive");
|
||||
|
||||
var progress = await uploadMedia.UploadAsync();
|
||||
if(progress.Status == Google.Apis.Upload.UploadStatus.Completed)
|
||||
{
|
||||
|
@ -95,8 +100,7 @@ namespace Bit.Publisher
|
|||
|
||||
Console.WriteLine("Version code {0} has been uploaded.", apk.VersionCode);
|
||||
|
||||
var trackRequest = new EditsResource.TracksResource.UpdateRequest(
|
||||
service,
|
||||
var trackRequest = service.Edits.Tracks.Update(
|
||||
new Track
|
||||
{
|
||||
VersionCodes = new List<int?> { apk.VersionCode }
|
||||
|
@ -108,10 +112,7 @@ namespace Bit.Publisher
|
|||
|
||||
Console.WriteLine("Track {0} has been updated.", updatedTrack.TrackValue);
|
||||
|
||||
var commitRequest = new EditsResource.CommitRequest(
|
||||
service,
|
||||
Package,
|
||||
edit.Id);
|
||||
var commitRequest = service.Edits.Commit(Package, edit.Id);
|
||||
var commitEdit = await commitRequest.ExecuteAsync();
|
||||
|
||||
Console.WriteLine("App edit with id {0} has been comitted.", commitEdit.Id);
|
||||
|
|
Loading…
Reference in a new issue