question

brendan avatar image
brendan asked

Login/Sign-in tokens and 3rd party services

Brendan Vanous
started a topic on Wed, 31 December 2014 at 11:26 AM

Question from a developer:

When using the login API calls for 3rd party services (Facebook, Game Center, Google, Steam), do I need to get the access token myself and pass it in as an argument?

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
brendan avatar image
brendan answered

Best Answer
Brendan Vanous said on Wed, 31 December 2014 at 11:27 AM

That's correct. If you have a look at the API calls in our Web API documentation pages (http://api.playfab.com/Documentation/Client), you'll see that we've provided more information on how to get these tokens in the Request Details for each call. The Web API docs are the best place to get more information on the details of how to use all of the PlayFab API calls.


27 Comments
Brendan Vanous said on Wed, 31 December 2014 at 11:27 AM

That's correct. If you have a look at the API calls in our Web API documentation pages (http://api.playfab.com/Documentation/Client), you'll see that we've provided more information on how to get these tokens in the Request Details for each call. The Web API docs are the best place to get more information on the details of how to use all of the PlayFab API calls.


johntube said on Fri, 09 January 2015 at 4:33 PM

This is the first time I'm doing this with Unity so I'm still confused and lost.

I've been looking for answers on how to get access token for Google's oauth 2.0 with Unity. I already did the first part and created a project on Google Developer Console, enabled the Google+ API and added the appropriate credentials. But since there is no quickstarter demo app for Unity I thought the C# was the closest. Now I need to add the Google+ API DLLs to the Unity project ? So why bother if I can look for another plugin in the Asset Store. I guess there is no plugin just for that as all the others do way more (e.g. SOOMLA profile) or are paid and Google Play Services related (e.g. prime31). But even the official Google Play Services plugin does not offer a way to get the access token as everything is "built in".

I can say that the only thing clear in my head is that the proper name of this process is "sign in with Google+" using "Google+ API" (it's not "Google Play Services" nor "Google").

The process is simple I need to send a post request to a URL with a client ID and a secret, then I need to show the html reply which is a consent page for the user to confirm then this pop-up/browser tab should be closed once the access token is returned. But what about refreshing the access token do I need to do it manually ?

So please can you help me here and tell me how do I implement a Google+ sign in button for PlayFab ? a tutorial link maybe...

And meanwhile I'm still waiting for the PlayFab-Photon marriage which was announced and acclaimed a while ago (maybe it was too early) !


Brendan Vanous said on Fri, 09 January 2015 at 7:16 PM

You may want to write to us at devrel@playfab.com if you have questions on multiple topics, but to answer your questions:

You are correct that the Google Play Services plugin does not provide direct access to the auth token. The authentication token to be used for Google sign-in to PlayFab is the one-time authorization code retrieved from a call to [getToken in the GoogleAuthUtil](http://developer.android.com/reference/com/google/android/gms/auth/GoogleAuthUtil.html#getToken(android.content.Context,%20java.lang.String,%20java.lang.String,%20android.os.Bundle) class. The refresh token isn't necessary in this flow, so you don't need to worry about that.

And no, the Photon partnership has come along very well. If you are a registered Premium tier developer with PlayFab, simply send us your App ID, and we'll get it moved to the PlayFab private Photon Cloud, so that you aren't changed anything by Exit Games. The technical integration is underway now, with authentication and webhooks-using-Cloud Script being the next pieces to be released.


johntube said on Sat, 10 January 2015 at 6:58 AM

So I need a plugin, I thought maybe I could use C#/Mono's System.Net.Sockets to do this (HTTP only) : something like this but it is deprecated. As there's no Unity plugin (the C#/.NET is not Mono friendly !) and I don't want to go the native Android plugin way with Unity just for that !

At least facebook has its own official Unity SDK !


zacb said on Mon, 12 January 2015 at 11:03 AM

Hey John,

I am one of the developer relations engineers here at PlayFab, and I will be helping your get set up with Google Play authentication.

I believe you can get up and running after:

Are you using / have you tried using the official Google plugin, the "play-games-plugin" (HERE)? This should give you a good wrapper library for many of the GooglePlay related API calls.
Following the guidance here seems to be a good walkthrough of working with the library to get the needed token: HERE.

Lastly, let me know if you need any additional help or have any remaining questions and I will be happy to assist.

-Zac


johntube said on Tue, 13 January 2015 at 6:21 PM

Hi Zac,

Thanks for the 2nd link, now I'm sure I'm not the only one having this problem. But since I'm using the last GPG Unity plugin (post doge) which became based on native C++ (a lot of Platform Invocation) instead of Java, the workaround does not work for me. So either I wait or I have to try working with Google APIs for Android (Native Java Plugin) inside Unity.

I've also noticed that there is no Link/UnlinkWithGoogleAccount API calls, should I add it to the features request list ?


zacb said on Wed, 14 January 2015 at 11:35 AM

Hey John,

Regarding Link/UnlinkWithGoogleAccount API calls, this has been brought up before internally, but we have not worked it into our formal sprint planning. Please feel free to add it to the features request list and we will triage the work into our plan.

In general there is a dearth of information regarding 3rd party integration for Unity3d projects. The information that is out there is very fragmented and often times outdated. I am working to provide a Unity3d sample project to remedy these issues.

From this project, you will be able to see how to integrate any of our supported third parties as well as how to use the majority of the APIs. The project will be posted to our gitHub and may also be the subject of a few blog posts.

I anticipate these will be completed within a couple weeks. In the mean time, I will be looking into how the Android parts of the project should work, and I will post back here as soon as I determine our path.

Lastly, I would definitely look around for plugins and libraries that can assist with the integration; and let us know if you find a library that does the job. We are always interested in learning more about the technologies that developers are using along side playfab.

All the best,

Zac


johntube said on Mon, 19 January 2015 at 3:11 PM

Hi Zac,

After struggling with a lot of heterogeneous technologies, IDEs and frameworks for a couple of days I've succeeded in Logging in to PlayFab with Google+.

I've chosen to create my own Android Unity Plugin. But first I had to take a look into the Android quickstart app for Google+ API and start by getting the token from there (which wasn't easy as the official example of getToken does not work. check these two useful links : common_problems, a_good_how_to). Then I tried Android Studio to create the library (.jar) plugin which was a dead end as Android Studio generates .aar files and you have to find a workaround to get the .jar. Well I've moved back to Eclipse and the good old ADT (preferably JDK 1.6 as mentioned in the Unity docs here).

Then I've faced a lot of errors, this time from Unity's side so after looking around in forums and stackoverflow I've found out that you need to copy the whole project folder into Assets\Plugins\Android<plugin_name> (source) and later I had to exclude the libs folder because of duplicate libraries. Another important thing is Android manifest files merging : you should focus mainly on the one found under Assets\Plugins\Android as it overrides the default one, so it should contain the permissions and the new main activity of the plugin so it should look like this :

<?xml version="1.0" encoding="utf-8"?>

<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.Company.Product" 
android:installLocation="preferExternal" android:theme="@android:style/Theme.NoTitleBar" android:versionCode="1" android:versionName="1.0">

 <supports-screens android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:xlargeScreens="true" android:anyDensity="true" />
  <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" /> 
<uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
    <uses-permission android:name="android.permission.USE_CREDENTIALS" />
  <application android:icon="@drawable/app_icon" android:label="@string/app_name" android:debuggable="true">
    <activity android:name="com.Company.Product.UnityBridge"
             android:label="@string/app_name"
       android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

  </application>

</manifest>

And here is the code of the Activity that overrides the UnityAndroidPlayer

package com.OrSomething.LettersNColors;

import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.content.IntentSender;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;

import com.google.android.gms.auth.GoogleAuthException;
import com.google.android.gms.auth.GoogleAuthUtil;
import com.google.android.gms.auth.UserRecoverableAuthException;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.Scopes;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.common.api.GoogleApiClient.ConnectionCallbacks;
import com.google.android.gms.plus.Plus;
import com.unity3d.player.UnityPlayer;
import com.unity3d.player.UnityPlayerActivity;

import java.io.IOException;

/**
 * Created by Hamza on 1/16/2015.
 */


public class UnityBridge extends UnityPlayerActivity implements ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener {
    public static Context mContext;

    private static final int RC_SIGN_IN = 0;
    static final int AUTH_CODE_REQUEST_CODE = 1;  // The request code

    private static final int DIALOG_PLAY_SERVICES_ERROR = 0;
    private static final String TAG = "g+-sign-in";

    // We use mSignInProgress to track whether user has clicked sign in.
    // mSignInProgress can be one of three values:
    //
    //       STATE_DEFAULT: The default state of the application before the user
    //                      has clicked 'sign in', or after they have clicked
    //                      'sign out'.  In this state we will not attempt to
    //                      resolve sign in errors and so will display our
    //                      Activity in a signed out state.
    //       STATE_SIGN_IN: This state indicates that the user has clicked 'sign
    //                      in', so resolve successive errors preventing sign in
    //                      until the user has successfully authorized an account
    //                      for our app.
    //   STATE_IN_PROGRESS: This state indicates that we have started an intent to
    //                      resolve an error, and so we should not start further
    //                      intents until the current intent completes.
    private int mSignInProgress;

    private static final int STATE_DEFAULT = 0;
    private static final int STATE_SIGN_IN = 1;
    private static final int STATE_IN_PROGRESS = 2;

    private static final String SAVED_PROGRESS = "sign_in_progress";

    // Used to store the PendingIntent most recently returned by Google Play
    // services until the user clicks 'sign in'.
    private PendingIntent mSignInIntent;

    // GoogleApiClient wraps our service connection to Google Play services and
    // provides access to the users sign in state and Google's APIs.
    private GoogleApiClient mGoogleApiClient;

    // Used to store the error code most recently returned by Google Play services
    // until the user clicks 'sign in'.
    private int mSignInError;

    private GoogleApiClient buildGoogleApiClient() {
        // When we build the GoogleApiClient we specify where connected and
        // connection failed callbacks should be returned, which Google APIs our
        // app uses and which OAuth 2.0 scopes our app requests.
        return new GoogleApiClient.Builder(this)
                .addConnectionCallbacks(this)
                .addOnConnectionFailedListener(this)
                .addApi(Plus.API, Plus.PlusOptions.builder().build())
                .addScope(Plus.SCOPE_PLUS_LOGIN)
                .build();
    }

    @Override
    protected void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);
        mContext = this;
        if (savedInstanceState != null) {
              mSignInProgress = savedInstanceState
                  .getInt(SAVED_PROGRESS, STATE_DEFAULT);
            }
        mGoogleApiClient = buildGoogleApiClient();
    }

    @Override
    protected void onStart() {
      super.onStart();
      mGoogleApiClient.connect();
    }

    private String token = null;

    /* onConnected is called when our Activity successfully connects to Google
     * Play services.  onConnected indicates that an account was selected on the
     * device, that the selected account has granted any requested permissions to
     * our app and that we were able to establish a service connection to Google
     * Play services.
     */
    @Override
    public void onConnected(Bundle connectionHint) {
        // Reaching onConnected means we consider the user signed in.
        Log.i(TAG, "onConnected");
    /*Plus.PeopleApi.loadVisible(mGoogleApiClient, null)
        .setResultCallback(this);*/
        task.execute();
    }

    /* onConnectionFailed is called when our Activity could not connect to Google
     * Play services.  onConnectionFailed indicates that the user needs to select
     * an account, grant permissions or resolve an error in order to sign in.
     */
    @Override
    public void onConnectionFailed(ConnectionResult result) {
        // Refer to the javadoc for ConnectionResult to see what error codes might
        // be returned in onConnectionFailed.
        Log.i(TAG, "onConnectionFailed: ConnectionResult.getErrorCode() = "
                + result.getErrorCode());

        if (result.getErrorCode() == ConnectionResult.API_UNAVAILABLE) {
            // An API requested for GoogleApiClient is not available. The device's current
            // configuration might not be supported with the requested API or a required component
            // may not be installed, such as the Android Wear application. You may need to use a
            // second GoogleApiClient to manage the application's optional APIs.
        } else if (mSignInProgress != STATE_IN_PROGRESS) {
            // We do not have an intent in progress so we should store the latest
            // error resolution intent for use when the sign in button is clicked.
            mSignInIntent = result.getResolution();
            mSignInError = result.getErrorCode();

            if (mSignInProgress == STATE_SIGN_IN) {
                // STATE_SIGN_IN indicates the user already clicked the sign in button
                // so we should continue processing errors until the user is signed in
                // or they click cancel.
                resolveSignInError();
            }
        }

        // In this sample we consider the user signed out whenever they do not have
        // a connection to Google Play services.
        //onSignedOut();
    }

    @Override
    protected void onSaveInstanceState(Bundle outState) {
      super.onSaveInstanceState(outState);
      outState.putInt(SAVED_PROGRESS, mSignInProgress);
    }

    @Override
    public void onConnectionSuspended(int cause) {
        // The connection to Google Play services was lost for some reason.
        // We call connect() to attempt to re-establish the connection or get a
        // ConnectionResult that we can attempt to resolve.
        mGoogleApiClient.connect();
    }

    /* Starts an appropriate intent or dialog for user interaction to resolve
     * the current error preventing the user from being signed in.  This could
     * be a dialog allowing the user to select an account, an activity allowing
     * the user to consent to the permissions being requested by your app, a
     * setting to enable device networking, etc.
     */
    private void resolveSignInError() {
        if (mSignInIntent != null) {
            // We have an intent which will allow our user to sign in or
            // resolve an error.  For example if the user needs to
            // select an account to sign in with, or if they need to consent
            // to the permissions your app is requesting.

            try {
                // Send the pending intent that we stored on the most recent
                // OnConnectionFailed callback.  This will allow the user to
                // resolve the error currently preventing our connection to
                // Google Play services.
                mSignInProgress = STATE_IN_PROGRESS;
                startIntentSenderForResult(mSignInIntent.getIntentSender(),
                        RC_SIGN_IN, null, 0, 0, 0);
            } catch (IntentSender.SendIntentException e) {
                Log.i(TAG, "Sign in intent could not be sent: "
                        + e.getLocalizedMessage());
                // The intent was canceled before it was sent.  Attempt to connect to
                // get an updated ConnectionResult.
                mSignInProgress = STATE_SIGN_IN;
                mGoogleApiClient.connect();
            }
        } else {
            // Google Play services wasn't able to provide an intent for some
            // error types, so we show the default Google Play services error
            // dialog which may still start an intent on our behalf if the
            // user can resolve the issue.
            //showDialog(DIALOG_PLAY_SERVICES_ERROR);
        }
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode,
                                    Intent data) {
        switch (requestCode) {
            case RC_SIGN_IN:
                if (resultCode == RESULT_OK) {
                    // If the error resolution was successful we should continue
                    // processing errors.
                    mSignInProgress = STATE_SIGN_IN;
                } else {
                    // If the error resolution was not successful or the user canceled,
                    // we should stop processing errors.
                    mSignInProgress = STATE_DEFAULT;
                }

                if (!mGoogleApiClient.isConnecting()) {
                    // If Google Play services resolved the issue with a dialog then
                    // onStart is not called so we need to re-attempt connection here.
                    mGoogleApiClient.connect();
                }
                break;
            case AUTH_CODE_REQUEST_CODE:
            {
                if (resultCode== RESULT_OK){
                    Log.i(TAG, "OK");
                }else {
                    Log.i(TAG, "ELSE");
                }
            }
        }
    }





    String getToken(){
        Bundle appActivities = new Bundle();
        appActivities.putString(GoogleAuthUtil.KEY_REQUEST_VISIBLE_ACTIVITIES,
                "http://schemas.google.com/AddActivity"); //*/
        //String scopes = "oauth2:server:client_id:"+CLIENT_ID+":api_scope:"+ Scopes.PLUS_LOGIN+ " "+SCOPE_2;
        String scopes = "oauth2:"+ Scopes.PLUS_LOGIN;
        String code = null;
        try {
            code = GoogleAuthUtil.getToken(
                    this,                                              // Context context
                    Plus.AccountApi.getAccountName(mGoogleApiClient),  // String accountName
                    scopes,                                            // String scope
                    appActivities                                      // Bundle bundle
            );

        } catch (IOException transientEx) {
            // network or server error, the call is expected to succeed if you try again later.
            // Don't attempt to call again immediately - the request is likely to
            // fail, you'll hit quotas or back-off.
            Log.i(TAG, "transient error encountered: " + transientEx.getMessage());
            //doExponentialBackoff();
            //return;
        } catch (UserRecoverableAuthException e) {
            // Requesting an authorization code will always throw
            // UserRecoverableAuthException on the first call to GoogleAuthUtil.getToken
            // because the user must consent to offline access to their data.  After
            // consent is granted control is returned to your activity in onActivityResult
            // and the second call to GoogleAuthUtil.getToken will succeed.
            //REQUEST_CODE
            startActivityForResult(e.getIntent(), AUTH_CODE_REQUEST_CODE);
            //return;
        } catch (GoogleAuthException authEx) {
            // Failure. The call is not expected to ever succeed so it should not be
            // retried.
            Log.e(TAG, "Unrecoverable authentication exception: " + authEx.getMessage(), authEx);

            // return;
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        return  code;
    }

    AsyncTask<Void, Void, String> task = new AsyncTask<Void, Void, String>() {
        @Override
        protected String doInBackground(Void... params) {
            return getToken();
        }

        @Override
        protected void onPostExecute(String code) {
            token = code;
            Log.i(TAG, "Access token retrieved:" + token);
            UnityPlayer.UnitySendMessage("PlayFabManager", "OnGoogleTokenReceived", token);
        }

    };

    public void GooglePlusSignIn(){
        Log.i(TAG, "GooglePlusSignIn");
        //mGoogleApiClient.connect();
        resolveSignInError();
    }

} 

And here's the C# part that does the Google sign in. This should be integrated in a script component in a GameObject named PlayFabManager to be able to receive the token from Unity.

public void LoginWithGoogle() {
        #if UNITY_ANDROID
        AndroidJNI.AttachCurrentThread();
        using (AndroidJavaClass javaClass = new AndroidJavaClass("com.OrSomething.LettersNColors.UnityBridge")) {
            using (AndroidJavaObject activity = javaClass.GetStatic<AndroidJavaObject>("mContext")) {
                activity.Call("GooglePlusSignIn");
            }
        }
        #endif
    }

    public void OnGoogleTokenReceived(String token) {
        LoginWithGoogleAccountRequest request = new LoginWithGoogleAccountRequest();
        request.AccessToken = token; 
        request.TitleId = PlayFabData.TitleId;
        request.CreateAccount = true;
        PlayFabClientAPI.LoginWithGoogleAccount(request, OnLoginCallback, OnPlayFabError);
    }

Of course you can add more Google+ features to the plugin in the UnityBridge Java class. You can also ask me anything related to this matter.

I hope this could help others or even be integrated into PlayFabSDK in the future ! But now I'm going to post a request for "Link/UnlinkWithGoogleAccount" and also "GetPlayFabIDsFromGoogleIDs" to be able to get the PlayFab players from Google+ circles.

Glad I did it and happy to share it with you.


zacb said on Fri, 23 January 2015 at 10:31 AM

Wow, very nice. That seems like it was quite an undertaking.

I will definitely be combing through the details of this soon.

We are planning out what we can do in terms of Unity Plugins, and your post definitely illustrates the pain that Unity developers have to deal with when wanting to access 'simple' native APIs.

Thanks Johntube for posting this, I will be in touch after we are a bit further down the plug-in planning path.

-z


luizcarlosfx said on Mon, 02 February 2015 at 7:39 AM

Do you still planning to post and example connecting 3rd party services to playfab? I still having problems with this. There are lot of plugins for this on unity asset store and even on github, but none of them give us access to the access token of the service, except for the facebook sdk for unity.


zacb said on Mon, 02 February 2015 at 2:57 PM

Hey Luiz,

We are working on some Unity sample code projects that lay out all the possible login pathways. I don't anticipate this will be publicly releasable for at least another month. We are also working on our own series of plugins to streamline this even more.

That being said, I have samples on a few of the pathways. Let me know which login's are you looking to start working with first, and I will do my best to get you started.

-zac


luizcarlosfx said on Mon, 02 February 2015 at 4:05 PM

These are great news! I'm glad found playfab. I was implementing my own server solution using Java and Spring MVC/oauth, but it would be such a pain and waste of time to implement all features you have already implemented. I want to use initially Facebook and Google plus login. Facebook is already solved and fully working, but my problem is with Google plus. I don't want to write native android code as Johntube did, because it would not solve the problem for IOS. Thanks


johntube said on Wed, 18 February 2015 at 7:42 PM

@zacb

I just found a new workaround using the Unity PlayGamesServices plugin here, I will post the results here as soon as I finish trying it.


zacb said on Thu, 19 February 2015 at 12:15 PM

Awesome John. I just read over the link. I am looking forward to seeing what you build.

Great find!

-z


marcusmingoransi said on Thu, 19 March 2015 at 8:16 AM

Hi John,

I don't have that UnityPlayerActivity class nor ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener interfaces.

can you help me?


johntube said on Thu, 19 March 2015 at 5:16 PM

@marcusmingoransi,

You have two options :

  1. [Recommended and easy] Wait fot PlayFab guys to release their next version of PlayFab's Android plugin that will get you the Google OAuth token.

  2. Make your own plugin like I did. You need to create a new Android Project (I used the same package name as I'm "overriding" the default main UnityPlayerActivity) with Eclipse. import GooglePlayServices library and Unity's development library for Android (classses.jar). If you need more details I can give you few links and the steps with more details.


zacb said on Fri, 20 March 2015 at 11:08 AM

@marcusminigoransi

All,

I wanted to pop in just to update you all on where we stand on the google+ Authentication plugin pieces.

At the moment we will not be wrapping in any standard google+ login authentication features. I will however, spend some time looking over the solutions posted here and the linked pages and include a barebones way to get the needed token for PlayFab authentication.

I have the first version of our login example code complete, pending internal code review, the google+ piece will have to wait until 2.0.

Also, if anyone has this working, we would be happy to promote your solution out to the general PlayFab developer community.

-Zac


johntube said on Sat, 21 March 2015 at 4:08 PM

@zacb

I just want to make sure I'm requesting the right token using the right scope. I know Brendan already mentioned that it's called one-time authorization code (1st one) but I've managed to make it work with the 2nd and I don't know if it's a variant of one-time authorization code but I don't think that PlayFab will be making GooglePlus API calls on the player's behalf when he's offline.

"oauth2:server:client_id:<SERVER-CLIENT-ID>:api_scope:<SCOPE1> <SCOPE2>" (one-time authorization code that your server exchanges for these two tokens)
"oauth2:<SCOPE1> <SCOPE2>" (If you do not require offline access)


arkhane84 said on Mon, 23 March 2015 at 6:33 AM

Hello guys, i'm posting here because i'm following the same path of troubles, wanting to auth players with their google account. So is there a simple method or unity example coming to get the needed token ?

Or maybe should i choose another flow for users to log, but i hesitate on which one is the more convenient for the players.

I want them to start playing anonymously and "officially" login at some point or when they need to access the shop. The LoginWithGoogleAccount way seems the best because LoginWithAndroidDeviceID is device bound (and only works in my editor, not on my testing devices) and LoginWithPlayFab asks the user to create a specific account (people are bored of creating accounts for everything). I can't use the facebook login right now because i'm using unity 5 and FB API isn't compatible yet.

By the way i can't wait to get my hands on the sample project zacb talked about, with examples for every way of logging with PlayFab API.

Thanks for any insight !


zacb said on Mon, 23 March 2015 at 2:16 PM

@johntube,

I will check in with our back-end engineers and post back with a series of clear steps that address the google+ login flow.

@all

You can find the login flow sample here. Note, that this does not include the google+ or steam bits yet; however, I feel like it is a good start and approach for having 1 login flow that accommodates most developers' and users' preferences.

This sample provides the following (official documentation in progress):

  • Attempts to log in with the previous method first

  • provides a way for users to manually select which pathway to use (saves login pathway in player prefs)

  • falls back to create a new account with device ID

This system is using a prefab that contains all the UI / View information which connects to a static class (PlayFabLoginCalls) to run all the PlayFab calls. I set up some events that you can have any other code listen for.

  • PlayFabLoginCalls.OnLoginFail += HandleOnLoginFail;
  • PlayFabLoginCalls.OnLoginSuccess += HandleOnLoginSuccess;
  • PlayFabLoginCalls.OnPlayfabCallbackSuccess += HandleCallbackSuccess;
  • PlayFabLoginCalls.OnPlayFabError += HandlePlayFabError;

2.0 will have:

  • steam & google+ support
  • how to link accounts together to allow someone to have their facebook and steam details attached to the device ID account.
  • updating usernames, passwords & emails to accounts that do no have one

I tried to keep this approachable but still informative. This can be a polarizing subject, so let me know your thoughts, and feedback.

Zac


Andrii.voloshchuk said on Tue, 07 April 2015 at 4:36 AM

@johntube,

Could You please share Your source project(unity plugin & project), I have made all the stuff, that You have written, but I am getting crash, when granting offline access, to my app. I could receive token, but app crashes.


zacb said on Tue, 07 April 2015 at 9:24 AM

@all,

I will be getting a blog post out on Thursday. Included will be a full unity sample detailing most of our login pathways as well as a walkthrough readme.

Hang tight, I know this is a high demand example, we are just spending the extra time time make sure that it is following all the best practices for login and account creations.

-z


Brendan Vanous said on Tue, 07 April 2015 at 11:43 AM

@johntube

Correct - we've been using the Google recommendation from their documentation, in order to ensure we're fully compatible. In your code example, you're requesting a re-usable token (the change to the Scopes), but if that's working fine for you in making purchases from Google Play via StartPurchase/PayForPurchase/ConfirmPurchase, there shouldn't be any issues with using it.

Brendan


johntube said on Tue, 07 April 2015 at 4:42 PM

@Andrii.voloshchuk

I think it's better if you wait until Thursday and get the Login samples v2 from PlayFab !

If you can't just send me an e-mail @ brice2k5[at]gmail.com and I will send you a demo project.


zacb said on Thu, 16 April 2015 at 10:17 AM

@ All,
Our new login sample is ready to go.

As always, keep us posted with your feedback on what we can do to make our services better!

-zac


Neil.campbell said on Thu, 21 May 2015 at 3:21 AM

I don't suppose anyone has an example of Steam authentication with Playfabs LoginWithSteamRequest() do they?

The example Unity project hasn't been updated with Steam and so I'm a little lost as to how to get the Steam Ticket. I'm using the Steamworks.net api in Unity.


zacb said on Wed, 03 June 2015 at 3:02 PM

@All,

I have not had a chance to get a full version of the login samples completed, however, we do now have a code sample for using LoginWithSteam in Unity3d with the Steamworks.net wrapper.

-zac

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.