Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Google SignIn with raw plugin and UPM #240

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions GoogleSignIn.asmdef
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"name": "GoogleSignin"
}
7 changes: 7 additions & 0 deletions GoogleSignIn.asmdef.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<!-- See https://github.com/googlesamples/unity-jar-resolver#usage for
how to configure dependencies -->
<androidPackages>
<androidPackage spec="com.google.android.gms:play-services-auth:16+">
<androidPackage spec="com.google.android.gms:play-services-auth:20+">
<androidSdkPackageIds>
<androidSdkPackageId>extra-google-m2repository</androidSdkPackageId>
</androidSdkPackageIds>
Expand All @@ -12,8 +12,7 @@

<!-- iOS Cocoapod dependencies can be specified by each iosPod element. -->
<iosPods>
<iosPod name="GoogleSignIn" version=">= 4.0.2" bitcodeEnabled="false"
minTargetSdk="6.0">
<iosPod name="GoogleSignIn" version="~> 6.2.4" bitcodeEnabled="false" minTargetSdk="6.0">
</iosPod>
</iosPods>
</dependencies>

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,27 +1,33 @@
Assets/GoogleSignIn/Editor/GoogleSignInDependencies.xml
Assets/GoogleSignIn/Editor/m2repository/com/google/signin/google-signin-support/1.0.1/google-signin-support-1.0.1.aar
Assets/GoogleSignIn/Editor/m2repository/com/google/signin/google-signin-support/1.0.1/google-signin-support-1.0.1.aar.md5
Assets/GoogleSignIn/Editor/m2repository/com/google/signin/google-signin-support/1.0.1/google-signin-support-1.0.1.aar.sha1
Assets/GoogleSignIn/Editor/m2repository/com/google/signin/google-signin-support/1.0.1/google-signin-support-1.0.1.pom
Assets/GoogleSignIn/Editor/m2repository/com/google/signin/google-signin-support/1.0.1/google-signin-support-1.0.1.pom.md5
Assets/GoogleSignIn/Editor/m2repository/com/google/signin/google-signin-support/1.0.1/google-signin-support-1.0.1.pom.sha1
Assets/GoogleSignIn/Future.cs
Assets/GoogleSignIn/GoogleSignIn.cs
Assets/GoogleSignIn/GoogleSignInConfiguration.cs
Assets/GoogleSignIn/GoogleSignInStatusCode.cs
Assets/GoogleSignIn/GoogleSignInUser.cs
Assets/GoogleSignIn/Impl/BaseObject.cs
Assets/GoogleSignIn/Impl/GoogleSignInImpl.cs
Assets/GoogleSignIn/Impl/NativeFuture.cs
Assets/GoogleSignIn/Impl/SignInHelperObject.cs
Assets/PlayServicesResolver/Editor/Google.VersionHandlerImpl_v1.2.89.0.dll
Assets/PlayServicesResolver/Editor/Google.IOSResolver_v1.2.89.0.dll
Assets/PlayServicesResolver/Editor/Google.VersionHandler.dll
Assets/PlayServicesResolver/Editor/Google.JarResolver_v1.2.89.0.dll
Assets/Plugins/iOS/GoogleSignIn/GoogleSignInAppController.mm
Assets/Plugins/iOS/GoogleSignIn/GoogleSignInAppController.h
Assets/Plugins/iOS/GoogleSignIn/GoogleSignIn.h
Assets/Plugins/iOS/GoogleSignIn/GoogleSignIn.mm
Assets/Parse/LICENSE
Assets/Parse/Plugins/Unity.Compat.dll
Assets/Parse/Plugins/Unity.Tasks.dll
Assets/PlayServicesResolver/Editor/Google.IOSResolver_v1.2.54.0.dll
Assets/PlayServicesResolver/Editor/Google.JarResolver_v1.2.54.0.dll
Assets/PlayServicesResolver/Editor/Google.VersionHandler.dll
Assets/PlayServicesResolver/Editor/Google.VersionHandlerImpl_v1.2.54.0.dll
Assets/PlayServicesResolver/Editor/play-services-resolver_v1.2.54.0.txt
Assets/Plugins/Android/native-googlesignin-release.aar
Assets/Plugins/iOS/GoogleSignIn/GoogleSignInAppController.h
Assets/Plugins/iOS/GoogleSignIn/GoogleSignInAppController.mm
Assets/SignInSample/MainScene.unity
Assets/SignInSample/SigninSampleScript.cs
Assets/GoogleSignIn/Impl/GoogleSignInImpl.cs
Assets/GoogleSignIn/Impl/SignInHelperObject.cs
Assets/GoogleSignIn/Impl/NativeFuture.cs
Assets/GoogleSignIn/Impl/BaseObject.cs
Assets/GoogleSignIn/GoogleSignIn.cs
Assets/GoogleSignIn/GoogleSignInConfiguration.cs
Assets/GoogleSignIn/Future.cs
Assets/GoogleSignIn/GoogleSignInUser.cs
Assets/GoogleSignIn/GoogleSignInStatusCode.cs
Assets/GoogleSignIn/Editor/GoogleSignInDependencies.xml
Assets/GoogleSignIn/Editor/GoogleSignInSupportDependencies.xml
Assets/GoogleSignIn/Editor/m2repository/com/google/signin/google-signin-support/maven-metadata.xml
Assets/GoogleSignIn/Editor/m2repository/com/google/signin/google-signin-support/maven-metadata.xml.md5
Assets/GoogleSignIn/Editor/m2repository/com/google/signin/google-signin-support/maven-metadata.xml.sha1
Assets/GoogleSignIn/Editor/m2repository/com/google/signin/google-signin-support/1.0.4/google-signin-support-1.0.4.pom.md5
Assets/GoogleSignIn/Editor/m2repository/com/google/signin/google-signin-support/1.0.4/google-signin-support-1.0.4.srcaar.sha1
Assets/GoogleSignIn/Editor/m2repository/com/google/signin/google-signin-support/1.0.4/google-signin-support-1.0.4.pom.sha1
Assets/GoogleSignIn/Editor/m2repository/com/google/signin/google-signin-support/1.0.4/google-signin-support-1.0.4.srcaar
Assets/GoogleSignIn/Editor/m2repository/com/google/signin/google-signin-support/1.0.4/google-signin-support-1.0.4.pom
Assets/GoogleSignIn/Editor/m2repository/com/google/signin/google-signin-support/1.0.4/google-signin-support-1.0.4.srcaar.md5

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ internal Future(FutureAPIImpl<T> impl) {
/// Gets the status.
/// </summary>
/// <value>The status is set when Pending == false.</value>
GoogleSignInStatusCode Status { get { return apiImpl.Status; } }
public GoogleSignInStatusCode Status { get { return apiImpl.Status; } }

/// <summary>
/// Gets the result.
/// </summary>
/// <value>The result is set when Pending == false and there is no error.
/// </value>
T Result { get { return apiImpl.Result; } }
public T Result { get { return apiImpl.Result; } }

/// <summary>
/// Waits for result then completes the TaskCompleationSource.
Expand All @@ -71,14 +71,29 @@ internal Future(FutureAPIImpl<T> impl) {
/// <param name="tcs">Tcs.</param>
internal IEnumerator WaitForResult(TaskCompletionSource<T> tcs) {
yield return new WaitUntil(() => !Pending);
if (Status == GoogleSignInStatusCode.Canceled) {
yield return null;
if (Status == GoogleSignInStatusCode.CANCELED) {
tcs.SetCanceled();
} else if (Status == GoogleSignInStatusCode.Success ||
Status == GoogleSignInStatusCode.SuccessCached) {
} else if (Status == GoogleSignInStatusCode.SUCCESS ||
Status == GoogleSignInStatusCode.SUCCESS_CACHE) {
tcs.SetResult(Result);
} else {
tcs.SetException(new GoogleSignIn.SignInException(Status));
}
}

internal async Task WaitForResultAsync(TaskCompletionSource<T> tcs)
{
while (Pending) await Task.Yield();
await Task.Yield();
if (Status == GoogleSignInStatusCode.CANCELED) {
tcs.SetCanceled();
} else if (Status == GoogleSignInStatusCode.SUCCESS ||
Status == GoogleSignInStatusCode.SUCCESS_CACHE) {
tcs.SetResult(Result);
} else {
tcs.SetException(new GoogleSignIn.SignInException(Status));
}
}
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public static GoogleSignInConfiguration Configuration {
if (theInstance == null || theConfiguration == value || theConfiguration == null) {
theConfiguration = value;
} else {
throw new SignInException(GoogleSignInStatusCode.DeveloperError,
throw new SignInException(GoogleSignInStatusCode.DEVELOPER_ERROR,
"DefaultInstance already created. " +
" Cannot change configuration after creation.");
}
Expand All @@ -87,20 +87,20 @@ public static GoogleSignInConfiguration Configuration {
public static GoogleSignIn DefaultInstance {
get {
if (theInstance == null) {
#if UNITY_ANDROID || UNITY_IOS
#if UNITY_EDITOR || UNITY_STANDALONE
theInstance = new GoogleSignIn(new GoogleSignInImplEditor(Configuration));
#elif UNITY_ANDROID || UNITY_IOS
theInstance = new GoogleSignIn(new GoogleSignInImpl(Configuration));
#else
theInstance = new GoogleSignIn(null);
throw new SignInException(
GoogleSignInStatusCode.DeveloperError,
"This platform is not supported by GoogleSignIn");
throw new SignInException(GoogleSignInStatusCode.DEVELOPER_ERROR,"This platform is not supported by GoogleSignIn");
#endif
}
return theInstance;
}
}

internal GoogleSignIn(GoogleSignInImpl impl) {
internal GoogleSignIn(ISignInImpl impl) {
this.impl = impl;
}

Expand All @@ -121,6 +121,14 @@ public Task<GoogleSignInUser> SignIn() {
return tcs.Task;
}

public Task<GoogleSignInUser> SignInAsync() {
var tcs = new TaskCompletionSource<GoogleSignInUser>();
impl.SignIn().WaitForResultAsync(tcs);
return tcs.Task;
}

public Future<GoogleSignInUser> SignInFuture() => impl.SignIn();

/// <summary>Starts the silent authentication process.</summary>
/// <remarks>
/// The authenication process is started and will attempt to sign in without
Expand All @@ -134,6 +142,14 @@ public Task<GoogleSignInUser> SignInSilently() {
return tcs.Task;
}

public Task<GoogleSignInUser> SignInSilentlyAsync() {
var tcs = new TaskCompletionSource<GoogleSignInUser>();
impl.SignInSilently().WaitForResultAsync(tcs);
return tcs.Task;
}

public Future<GoogleSignInUser> SignInSilentlyFuture() => impl.SignInSilently();

/// <summary>
/// Signs out the User.
/// </summary>
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ public class GoogleSignInConfiguration {
/// See the README for more details.
/// </remarks>
public bool UseGameSignIn = false;
#if UNITY_EDITOR || UNITY_STANDALONE
/// <summary>Client Secret for used in editor and desktop platform</summary>
/// <remarks>Required for requesting auth code or id token in editor</remarks>
public string ClientSecret = null;
#endif
/// <summary>Web client id associated with this app.</summary>
/// <remarks>Required for requesting auth code or id token.</remarks>
public string WebClientId = null;
Expand All @@ -45,7 +50,7 @@ public class GoogleSignInConfiguration {
/// <summary>Request id token, requires consent.</summary>
public bool RequestIdToken = false;
/// <summary>Request profile information, requires consent.</summary>
public bool RequestProfile = false;
public bool RequestProfile = true;
/// <summary>Hides popup UIs from games services.</summary>
/// <remarks>Used with games signin to show or hide the connecting popup UI
/// and to associate an invisible view for other popups. This is
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

53 changes: 53 additions & 0 deletions GoogleSignIn/GoogleSignInStatusCode.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// <copyright file="GoogleSignInStatusCode.cs" company="Google Inc.">
// Copyright (C) 2017 Google Inc. All Rights Reserved.
//
// 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.
// </copyright>

namespace Google {

/// <summary>
/// Status code for the SignIn operations.
/// </summary>
/// <remarks>All successful status codes are less than or equal to 0.
/// </remarks>
public enum GoogleSignInStatusCode {
SUCCESS_CACHE = -1,
SUCCESS = 0,
[System.Obsolete]
SERVICE_MISSING = 1,
[System.Obsolete]
SERVICE_VERSION_UPDATE_REQUIRED = 2,
[System.Obsolete]
SERVICE_DISABLED = 3,
SIGN_IN_REQUIRED = 4,
INVALID_ACCOUNT = 5,
RESOLUTION_REQUIRED = 6,
NETWORK_ERROR = 7,
INTERNAL_ERROR = 8,
SERVICE_INVALID = 9,
DEVELOPER_ERROR = 10,
LICENSE_CHECK_FAILED = 11,
ERROR = 13,
INTERRUPTED = 14,
TIMEOUT = 15,
CANCELED = 16,
API_NOT_CONNECTED = 17,
DEAD_CLIENT = 18,
REMOTE_EXCEPTION = 19,
CONNECTION_SUSPENDED_DURING_CALL = 20,
RECONNECTION_TIMED_OUT_DURING_UPDATE = 21,
RECONNECTION_TIMED_OUT = 22
}
} // namespace GoogleSignIn

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading