当前位置: 首页>>代码示例>>Java>>正文


Java Auth类代码示例

本文整理汇总了Java中com.google.android.gms.auth.api.Auth的典型用法代码示例。如果您正苦于以下问题:Java Auth类的具体用法?Java Auth怎么用?Java Auth使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Auth类属于com.google.android.gms.auth.api包,在下文中一共展示了Auth类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: LoginGoogle

import com.google.android.gms.auth.api.Auth; //导入依赖的package包/类
public LoginGoogle(final Context context, SignInButton button, final Activity act, PreferencesShared pref) {
    this.context = context;
    preferencesShared = pref;
    GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN).requestIdToken("473547758853-nm840bumsu5km04gbgtdee1fhtod1ji6.apps.googleusercontent.com").build();
    gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) .requestScopes(new Scope(Scopes.PLUS_LOGIN)).requestScopes(new Scope(Scopes.PLUS_ME)).requestEmail().requestIdToken("473547758853-nm840bumsu5km04gbgtdee1fhtod1ji6.apps.googleusercontent.com").build();
    mGoogleApiClient = new GoogleApiClient.Builder(context.getApplicationContext())
            .addApi(Auth.GOOGLE_SIGN_IN_API, gso)
            .addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this)
            .build();

    button.setSize(SignInButton.SIZE_STANDARD);
    button.setScopes(gso.getScopeArray());

    button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient);
            act.startActivityForResult(signInIntent, 101);

        }
    });
}
 
开发者ID:TudorRosca,项目名称:enklave,代码行数:24,代码来源:LoginGoogle.java

示例2: initGoogleApiClient

import com.google.android.gms.auth.api.Auth; //导入依赖的package包/类
private void initGoogleApiClient() {
    final GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
            .requestEmail()
            .requestProfile()
            .requestScopes(new Scope(SCOPE_PICASA))
            .build();
    googleApiClient = new GoogleApiClient.Builder(activity)
            .enableAutoManage(activity,
                    connectionResult -> emitter.onError(new SignInException("Connecting", connectionResult.getErrorMessage(), connectionResult.getErrorCode())))
            .addApi(Auth.GOOGLE_SIGN_IN_API, gso)
            .addConnectionCallbacks(new GoogleApiClient.ConnectionCallbacks() {
                @Override
                public void onConnected(@Nullable Bundle bundle) {
                    actWhenConnected();
                }

                @Override
                public void onConnectionSuspended(int i) {

                }
            })
            .build();
}
 
开发者ID:yosriz,项目名称:RxGooglePhotos,代码行数:24,代码来源:GoogleSignOutOnSubscribe.java

示例3: onClick

import com.google.android.gms.auth.api.Auth; //导入依赖的package包/类
@Override
public void onClick(View view) {
    switch (view.getId()) {
        case R.id.sign_in_button:
            Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient);
            startActivityForResult(signInIntent, 1);
            break;
        case R.id.sign_out_button:
            Auth.GoogleSignInApi.signOut(mGoogleApiClient).setResultCallback(
                    new ResultCallback<Status>() {
                        @Override
                        public void onResult(Status status) {
                            Log.w("credentials","Status: "+ status.getStatus());
                            Log.w("credentials","StatusMessage: "+ status.getStatusMessage());
                        }
                    });
            break;
    }
}
 
开发者ID:karlotoy,项目名称:perfectTune,代码行数:20,代码来源:SignInActivity.java

示例4: handleSignInResult

import com.google.android.gms.auth.api.Auth; //导入依赖的package包/类
/**
 * Handle google sign in result
 *
 * @param result the GoogleSignInResult result
 */
public void handleSignInResult(final GoogleSignInResult result) {
    if (result.isSuccess()) {
        GoogleSignInAccount account = result.getSignInAccount();
        mGoogleApiClient.disconnect();
        verifySmartLockIsEnabled(new RxAccount(account));
    }
    else {
        // delete credential
        if(mCredential != null) {
            Auth.CredentialsApi.delete(mGoogleApiClient, mCredential).setResultCallback(new ResultCallback<Status>() {
                @Override
                public void onResult(@NonNull Status status) {
                    mGoogleApiClient.disconnect();
                    mAccountSubject.onError(new Throwable(result.getStatus().toString()));
                }
            });
        }
        else {
            mGoogleApiClient.disconnect();
            mAccountSubject.onError(new Throwable(result.getStatus().toString()));
        }
    }
}
 
开发者ID:pchmn,项目名称:RxSocialAuth,代码行数:29,代码来源:RxGoogleAuthFragment.java

示例5: onCreate

import com.google.android.gms.auth.api.Auth; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_sign_in);

    // Assign fields
    mSignInButton = (SignInButton) findViewById(R.id.sign_in_button);

    // Set click listeners
    mSignInButton.setOnClickListener(this);

    // Configure Google Sign In
    GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
            .requestIdToken(getString(R.string.default_web_client_id))
            .requestEmail()
            .build();
    mGoogleApiClient = new GoogleApiClient.Builder(this)
            .enableAutoManage(this /* FragmentActivity */, this /* OnConnectionFailedListener */)
            .addApi(Auth.GOOGLE_SIGN_IN_API, gso)
            .build();

    // Initialize FirebaseAuth
}
 
开发者ID:firebase,项目名称:friendlychat-android,代码行数:24,代码来源:SignInActivity.java

示例6: onActivityResult

import com.google.android.gms.auth.api.Auth; //导入依赖的package包/类
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    // Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...);
    if (requestCode == RC_SIGN_IN) {
        GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
        if (result.isSuccess()) {
            // Google Sign In was successful, authenticate with Firebase
            GoogleSignInAccount account = result.getSignInAccount();
            firebaseAuthWithGoogle(account);
        } else {
            // Google Sign In failed
            Log.e(TAG, "Google Sign In failed.");
        }
    }
}
 
开发者ID:firebase,项目名称:friendlychat-android,代码行数:18,代码来源:SignInActivity.java

示例7: login

import com.google.android.gms.auth.api.Auth; //导入依赖的package包/类
@Override
public void login(@NonNull SmartLoginConfig config) {
    GoogleApiClient apiClient = config.getGoogleApiClient();
    Activity activity = config.getActivity();

    if (apiClient == null) {
        GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
                .requestEmail()
                .requestProfile()
                .build();

        apiClient = new GoogleApiClient.Builder(activity)
                .addApi(Auth.GOOGLE_SIGN_IN_API, gso)
                .build();
    }

    ProgressDialog progress = ProgressDialog.show(activity, "", activity.getString(R.string.logging_holder), true);
    Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(apiClient);
    activity.startActivityForResult(signInIntent, Constants.GOOGLE_LOGIN_REQUEST);
    progress.dismiss();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:22,代码来源:GoogleLogin.java

示例8: onActivityResult

import com.google.android.gms.auth.api.Auth; //导入依赖的package包/类
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    mCallbackManager.onActivityResult(requestCode, resultCode, data);
    twitter.onActivityResult(requestCode, resultCode, data);
    // Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...);
    if (requestCode == RC_SIGN_IN) {
        GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
        if (result.isSuccess()) {
            // Google Sign In was successful, authenticate with Firebase
            GoogleSignInAccount account = result.getSignInAccount();
            firebaseAuthWithGoogle(account);
        } else {
            checkconnection();
        }
    }
}
 
开发者ID:Shobhit-pandey,项目名称:CollegeDoc,代码行数:18,代码来源:MainActivity.java

示例9: onActivityResult

import com.google.android.gms.auth.api.Auth; //导入依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (requestCode == RC_SIGNIN_GOOGLE) {
        GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
        if (result.isSuccess()) {
            GoogleSignInAccount account = result.getSignInAccount();
            AuthCredential credential = GoogleAuthProvider.getCredential(account.getIdToken(), null);
            auth.signInWithCredential(credential)
                    .addOnCompleteListener(this, this);
        } else
            onFailure(result.getStatus().toString());
    } else
        callbackManager.onActivityResult(requestCode, resultCode, data);
}
 
开发者ID:whirlwind-studios,项目名称:School1-Android,代码行数:17,代码来源:SigninActivity.java

示例10: setUpGoogleAuth

import com.google.android.gms.auth.api.Auth; //导入依赖的package包/类
private void setUpGoogleAuth() {
    // Configure sign-in to request the user's ID, email address, idToken and basic profile.
    GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
            .requestIdToken(getString(R.string.client_id))
            .requestEmail()
            .build();

    // Build a GoogleApiClient with access to the Google Sign-In API and the options specified by gso.
    GoogleApiClient googleApiClient = new GoogleApiClient.Builder(this)
            .enableAutoManage(this, this)
            .addApi(Auth.GOOGLE_SIGN_IN_API, gso)
            .addApi(AppIndex.API).build();

    // Set GoogleApiClient into AppRunnest instance to be used in the rest of the application.
    ((AppRunnest) getApplication()).setApiClient(googleApiClient);
}
 
开发者ID:IrrilevantHappyLlamas,项目名称:Runnest,代码行数:17,代码来源:LoginActivity.java

示例11: pluginInitialize

import com.google.android.gms.auth.api.Auth; //导入依赖的package包/类
@Override
protected void pluginInitialize() {
    Log.d(TAG, "Starting Firebase Authentication plugin");

    this.firebaseAuth = FirebaseAuth.getInstance();
    this.phoneAuthProvider = PhoneAuthProvider.getInstance();

    Context context = this.cordova.getActivity().getApplicationContext();
    String defaultClientId = getDefaultClientId(context);
    GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
            .requestIdToken(defaultClientId)
            .requestEmail()
            .requestProfile()
            .build();

    googleApiClient = new GoogleApiClient.Builder(context)
            .addApi(Auth.GOOGLE_SIGN_IN_API, gso)
            .build();
    googleApiClient.connect();
    //firebaseAuth = FirebaseAuth.getInstance();
    //firebaseAuth.addAuthStateListener(this);
}
 
开发者ID:kanodeveloper,项目名称:cordova-plugin-firebase-performance-ka,代码行数:23,代码来源:FirebaseAuthenticationPlugin.java

示例12: onActivityResult

import com.google.android.gms.auth.api.Auth; //导入依赖的package包/类
public void onActivityResult(int requestCode, int resultCode, Intent data) {
	// Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...);

	if (requestCode == Utils.FIREBASE_GOOGLE_SIGN_IN) {
		GoogleSignInResult result =
		Auth.GoogleSignInApi.getSignInResultFromIntent(data);

		isIntentInProgress = false;

		if (!mGoogleApiClient.isConnecting()) { mGoogleApiClient.connect(); }

		if (result.isSuccess()) {
			// Google Sign In was successful, authenticate with Firebase

			GoogleSignInAccount account = result.getSignInAccount();
			firebaseAuthWithGoogle(account);
		} else {
			// Google Sign In failed, update UI appropriately
			// updateUI(null);
		}
	}
}
 
开发者ID:FrogSquare,项目名称:GodotFireBase,代码行数:23,代码来源:GoogleSignIn.java

示例13: signOut

import com.google.android.gms.auth.api.Auth; //导入依赖的package包/类
protected void signOut(GoogleApiClient googleApiClient){
    mAuth.signOut();

    Auth.GoogleSignInApi.signOut(googleApiClient).setResultCallback(new ResultCallback<Status>() {
        @Override
        public void onResult(@NonNull Status status) {
            Toast toast = Toast.makeText(AuthBaseActivity.this,
                    mResources.getString(R.string.sign_out_text),
                    Toast.LENGTH_SHORT);
            toast.setGravity(Gravity.CENTER, 0, 100);
            toast.show();

            Intent i = new Intent(AuthBaseActivity.this, SignInActivity.class);
            AuthBaseActivity.this.startActivity(i);
            AuthBaseActivity.this.finish();
        }
    });
}
 
开发者ID:AviralGarg1993,项目名称:VR-One,代码行数:19,代码来源:AuthBaseActivity.java

示例14: onActivityResult

import com.google.android.gms.auth.api.Auth; //导入依赖的package包/类
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    callbackManager.onActivityResult(requestCode, resultCode, data);

    // Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...);
    if (requestCode == RC_SIGN_IN) {
        GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
        if (result.isSuccess()) {
            // Google Sign In was successful, authenticate with Firebase
            GoogleSignInAccount account = result.getSignInAccount();
            setSessionManagement();
            firebaseAuthWithGoogle(account);
        } else {
            // Google Sign In failed, update UI appropriately
            // ...
        }
    }


}
 
开发者ID:yashovardhanagrawal,项目名称:AddyHINT17,代码行数:22,代码来源:SignIn.java

示例15: onActivityResult

import com.google.android.gms.auth.api.Auth; //导入依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    // Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...);
    if (requestCode == CRDConstants.REQUEST_CODE_GOOGLE_SIGN_IN) {
        GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
        if (result.isSuccess()) {
            // Google Sign In was successful, authenticate with Firebase
            GoogleSignInAccount account = result.getSignInAccount();
            logInToFirebaseWithGoogleSignIn(account);
        } else {
            Log.e(CRDAuthActivity.class.getName(), "onActivityResult().REQUEST_CODE_GOOGLE_SIGN_IN FAILED ! " + "getSignInResultFromIntent = [" + result.getStatus() + "]");
        }
    }
}
 
开发者ID:NinoDLC,项目名称:CineReminDay,代码行数:17,代码来源:CRDAuthActivity.java


注:本文中的com.google.android.gms.auth.api.Auth类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。