Class SheetsServiceProvider
The Sheets service provider performs the authentication to Google and keeps track of the authentication tokens so that you do not need to authenticate each time. The Sheets service provider also includes general sheet properties, such as default sheet styles, that are used when creating a new sheet.
Inherited Members
Namespace: UnityEditor.Localization.Plugins.Google
Assembly: Unity.Localization.Editor.dll
Syntax
[CreateAssetMenu(fileName = "Google Sheets Service", menuName = "Localization/Google Sheets Service")]
[HelpURL("https://developers.google.com/sheets/api/guides/authorizing#AboutAuthorization")]
public class SheetsServiceProvider : ScriptableObject, IGoogleSheetsService, ISerializationCallbackReceiver
Examples
Unity recommends to have a SheetsServiceProvider asset pre-configured for use, however this example does create a new one.
// The Sheets service provider performs the authentication and keeps track of the
// authentication tokens so that we do not need to authenticate each time.
// It is recommended to have a SheetsServiceProvider asset pre-configured for
// use however in this example we will create a new one.
var sheetServiceProvider = ScriptableObject.CreateInstance<SheetsServiceProvider>();
// OAuth is required when making changes. See the docs for info setting up OAuth credentials.
sheetServiceProvider.SetOAuthCredentials("some-client-id", "some-client-secret");
return sheetServiceProvider;
Properties
Name | Description |
---|---|
ApiKey | The API Key to use when using APIKey authentication. |
ApplicationName | The name of the application that will be sent when connecting. |
Authentication | The authorization methodology to use. See https://developers.google.com/sheets/api/guides/authorizing |
ClientId | Client Id when using OAuth authentication. See also SetOAuthCredentials(string) |
ClientSecret | Client secret when using OAuth authentication. See also SetOAuthCredentials(string) |
DataStore | Used to make sure the access and refresh tokens persist. Uses a FileDataStore by default with "Library/Google/{name}" as the path. |
NewSheetProperties | Properties to use when creating a new Google Spreadsheet sheet. |
Service | The Google Sheet service that will be created using the Authorization API. |
Methods
Name | Description |
---|---|
AuthoizeOAuth() | Call to preauthorize when using OAuth authorization. This will cause a browser to open a Google authorization page after which the token will be stored in IDataStore so that this does not need to be done each time. If this is not called then the first time Service is called it will be performed then. |
AuthorizeOAuth() | Call to preauthorize when using OAuth authorization. This will cause a browser to open a Google authorization page after which the token will be stored in IDataStore so that this does not need to be done each time. If this is not called then the first time Service is called it will be performed then. |
AuthorizeOAuthAsync(CancellationToken) | Call to preauthorize when using OAuth authorization. This will cause a browser to open a Google authorization page after which the token will be stored in IDataStore so that this does not need to be done each time. If this is not called then the first time Service is called it will be performed then. |
SetApiKey(string) | Set the API Key. An API key can only be used for reading from a public Google Spreadsheet. |
SetOAuthCredentials(string) | Enable OAuth 2.0 authentication and extract the ClientId and ClientSecret from the supplied json. |
SetOAuthCredentials(string, string) | Enable OAuth 2.0 authentication with the provided client Id and client secret. |
SetOAuthCrendtials(string) | Enable OAuth 2.0 authentication and extract the ClientId and ClientSecret from the supplied json. |
SetOAuthCrendtials(string, string) | Enable OAuth 2.0 authentication and extract the ClientId and ClientSecret from the supplied json. |