Skip to content

iOS AuthCode return void #66

@alexmaroldi

Description

@alexmaroldi

Hi,
I have found this issue on iOS: after the first SignIn call, where I correctly retrieve the AuthCode after task completion, other calls to SignIn (or SignInSilently) always return empty string for task.Result.AuthCode

Activity

mckoupel

mckoupel commented on Oct 26, 2018

@mckoupel

The same problem for me. Any ideas?
I'm trying to get access token using auth code but auth code is empty(

alexmaroldi

alexmaroldi commented on Oct 26, 2018

@alexmaroldi
Author

@mckoupel sadly it seems correct for Google policy on iOS.
I solved by getting AccessToken after the first AuthCode and use that for login with server. I don't know if this could help you.

mckoupel

mckoupel commented on Oct 26, 2018

@mckoupel

Ok.
How you get access token using AuthCode? If I use something like this

 IEnumerator GetAccessToken(string authcode)
{
        WWWForm form = new WWWForm();
        form.AddField("client_id", webclientid);
        form.AddField("client_secret", "");
        form.AddField("grant_type", "authorization_code");
        form.AddField("code", authcode);

        UnityWebRequest www = UnityWebRequest.Post("https://www.googleapis.com/oauth2/v4/token", form);
        yield return www.SendWebRequest();

        if (www.isNetworkError || www.isHttpError)
        {
            Debug.Log(www.error);
        }
        else
        {
			
	 //Access token response
          Debug.Log(www.downloadHandler.text);

     }
 }

I always have 401 unauthorized...
Maybe something wrong with authcode lifetime?

mckoupel

mckoupel commented on Oct 26, 2018

@mckoupel

And one more question. Is any way to reset authcode? After sign out I still have empty string in authcode. Sometimes authode not empty but I can't understand dependence. Maybe authcode lifecycle don't depend on sign out...Or something else wrong

novavision

novavision commented on Dec 14, 2018

@novavision

Same here.. only 1st time I get AuthCode, and all other sign in attempts return empty field. Tried to remove app and reinstall - all the same.

thsbrown

thsbrown commented on Aug 6, 2019

@thsbrown

Also having this issue. I thought ForceTokenRefresh = true could solve the issue as it looks like that would force consent, but it's not looking like it's working.

thsbrown

thsbrown commented on Aug 6, 2019

@thsbrown
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @alexmaroldi@thsbrown@novavision@mckoupel

        Issue actions

          iOS AuthCode return void · Issue #66 · googlesamples/google-signin-unity