TokenClient.cs 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. // <copyright file="TokenClient.cs" company="Google Inc.">
  2. // Copyright (C) 2015 Google Inc.
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. //
  8. // http://www.apache.org/licenses/LICENSE-2.0
  9. //
  10. // Unless required by applicable law or agreed to in writing, software
  11. // distributed under the License is distributed on an "AS IS" BASIS,
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. // See the License for the specific language governing permissions and
  14. // limitations under the License.
  15. // </copyright>
  16. #if UNITY_ANDROID
  17. namespace GooglePlayGames
  18. {
  19. using GooglePlayGames.BasicApi;
  20. using System;
  21. internal interface TokenClient
  22. {
  23. /// <summary>
  24. /// Gets the user's email.
  25. /// </summary>
  26. /// <remarks>The email address returned is selected by the user from the accounts present
  27. /// on the device. There is no guarantee this uniquely identifies the player.
  28. /// For unique identification use the id property of the local player.
  29. /// The user can also choose to not select any email address, meaning it is not
  30. /// available.</remarks>
  31. /// <returns>The user email or null if not authenticated or the permission is
  32. /// not available.</returns>
  33. string GetEmail();
  34. string GetAuthCode();
  35. string GetIdToken();
  36. /// <summary>
  37. /// Gets another server auth code.
  38. /// </summary>
  39. /// <remarks>This method should be called after authenticating, and exchanging
  40. /// the initial server auth code for a token. This is implemented by signing in
  41. /// silently, which if successful returns almost immediately and with a new
  42. /// server auth code.
  43. /// </remarks>
  44. /// <param name="reAuthenticateIfNeeded">Calls Authenticate if needed when
  45. /// retrieving another auth code. </param>
  46. /// <param name="callback">Callback.</param>
  47. void GetAnotherServerAuthCode(bool reAuthenticateIfNeeded,
  48. Action<string> callback);
  49. void Signout();
  50. void SetRequestAuthCode(bool flag, bool forceRefresh);
  51. void SetRequestEmail(bool flag);
  52. void SetRequestIdToken(bool flag);
  53. void SetWebClientId(string webClientId);
  54. void SetAccountName(string accountName);
  55. void AddOauthScopes(params string[] scopes);
  56. void SetHidePopups(bool flag);
  57. void FetchTokens(bool silent, Action<int> callback);
  58. void RequestPermissions(string[] scopes, Action<SignInStatus> callback);
  59. bool HasPermissions(string[] scopes);
  60. }
  61. }
  62. #endif