-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #124 from RevealBi/feat/google-sheet-datasource
Feat/google sheet datasource
- Loading branch information
Showing
14 changed files
with
265 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"type": "service_account", | ||
"project_id": "testreveal-henry", | ||
"private_key_id": "", | ||
"private_key": "", | ||
"client_email": "[email protected]", | ||
"client_id": "108057201146814272043", | ||
"auth_uri": "https://accounts.google.com/o/oauth2/auth", | ||
"token_uri": "https://oauth2.googleapis.com/token", | ||
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs", | ||
"client_x509_cert_url": "", | ||
"universe_domain": "googleapis.com" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
using Reveal.Sdk.Data; | ||
using Reveal.Sdk.Data; | ||
using Reveal.Sdk.Data.Amazon.Athena; | ||
using Reveal.Sdk.Data.Amazon.S3; | ||
using Reveal.Sdk.Data.Microsoft.AnalysisServices; | ||
|
@@ -17,6 +17,9 @@ | |
using Reveal.Sdk.Data.OData; | ||
using Reveal.Sdk.Data.Oracle; | ||
using Reveal.Sdk.Data.Microsoft.SynapseAnalytics; | ||
using Google.Apis.Auth.OAuth2; | ||
using System.IO; | ||
using System.Text; | ||
|
||
namespace Sandbox.RevealSDK | ||
{ | ||
|
@@ -40,6 +43,12 @@ public Task<IRVDataSourceCredential> ResolveCredentialsAsync(RVDashboardDataSour | |
else if (dataSource is RVNativeAnalysisServicesDataSource) | ||
{ | ||
userCredential = new RVUsernamePasswordDataSourceCredential("username", "password", "domain"); | ||
} | ||
else if (dataSource is RVGoogleDriveDataSource) | ||
{ | ||
var _token = RetrieveGoogleDriveBearerToken(); | ||
|
||
userCredential = new RVBearerTokenDataSourceCredential(_token, null); | ||
} | ||
else if (dataSource is RVSnowflakeDataSource) | ||
{ | ||
|
@@ -72,10 +81,6 @@ public Task<IRVDataSourceCredential> ResolveCredentialsAsync(RVDashboardDataSour | |
else if (dataSource is RVGoogleDriveDataSource) | ||
{ | ||
userCredential = new RVBearerTokenDataSourceCredential("token", null); | ||
} | ||
else if(dataSource is RVGoogleSheetDataSource) | ||
{ | ||
|
||
} | ||
else if(dataSource is RVHttpAnalysisServicesDataSource) | ||
{ | ||
|
@@ -112,5 +117,36 @@ public Task<IRVDataSourceCredential> ResolveCredentialsAsync(RVDashboardDataSour | |
|
||
return Task.FromResult(userCredential); | ||
} | ||
|
||
internal string RetrieveGoogleDriveBearerToken() | ||
{ | ||
var jsonKey = @" | ||
{ | ||
""type"": ""service_account"", | ||
""project_id"": ""testreveal-henry"", | ||
""private_key_id"": ""***"", | ||
""private_key"": ""******"", | ||
""client_email"": ""[email protected]"", | ||
""client_id"": ""***"", | ||
""auth_uri"": ""https://accounts.google.com/o/oauth2/auth"", | ||
""token_uri"": ""https://oauth2.googleapis.com/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/henrytestreveal%40testreveal-henry.iam.gserviceaccount.com"", | ||
""universe_domain"": ""googleapis.com"" | ||
} | ||
"; | ||
|
||
var memoryStream = new MemoryStream(); | ||
byte[] jsonKeyBytes = Encoding.UTF8.GetBytes(jsonKey); | ||
memoryStream.Write(jsonKeyBytes, 0, jsonKeyBytes.Length); | ||
memoryStream.Seek(0, SeekOrigin.Begin); | ||
var credential = GoogleCredential.FromStream(memoryStream).CreateScoped("https://www.googleapis.com/auth/drive", | ||
"https://www.googleapis.com/auth/userinfo.email", | ||
"https://www.googleapis.com/auth/userinfo.profile"); | ||
|
||
var accessToken = credential.UnderlyingCredential.GetAccessTokenForRequestAsync().Result; | ||
|
||
return accessToken; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.