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


Java OkAuthType类代码示例

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


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

示例1: login

import ru.ok.android.sdk.util.OkAuthType; //导入依赖的package包/类
@ReactMethod
public void login(final ReadableArray scope, final Promise promise) {
    int scopeSize = scope.size();
    final String[] scopeArray = new String[scopeSize];
    for (int i = 0; i < scopeSize; i++) {
        scopeArray[i] = scope.getString(i);
    }
    loginPromise = promise;
    odnoklassniki.checkValidTokens(new OkListener() {
        @Override
        public void onSuccess(JSONObject json) {
            Log.d(LOG, "Check valid token success");
            resolveWithCurrentUser(json.optString(Shared.PARAM_ACCESS_TOKEN), json.optString(Shared.PARAM_SESSION_SECRET_KEY));
        }

        @Override
        public void onError(String error) {
            Log.d(LOG, "Valid token wasn't found at login, requesting authorization");
            odnoklassniki.requestAuthorization(getCurrentActivity(), redirectUri, OkAuthType.ANY, scopeArray);
        }
    });
}
 
开发者ID:doomsower,项目名称:react-native-odnoklassniki-login,代码行数:23,代码来源:RNOdnoklassnikiModule.java

示例2: onCreate

import ru.ok.android.sdk.util.OkAuthType; //导入依赖的package包/类
@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.ok_auth_activity);
    prepareWebView();

    Bundle bundle = savedInstanceState != null ? savedInstanceState : getIntent().getExtras();
    mAppId = bundle.getString(Shared.PARAM_CLIENT_ID);
    mAppKey = bundle.getString(Shared.PARAM_APP_KEY);
    mRedirectUri = bundle.getString(Shared.PARAM_REDIRECT_URI);
    if (mRedirectUri == null) {
        mRedirectUri = DEFAULT_REDIRECT_URI;
    }
    mScopes = bundle.getStringArray(Shared.PARAM_SCOPES);
    authType = (OkAuthType) bundle.getSerializable(Shared.PARAM_AUTH_TYPE);
    allowDebugOkSso = bundle.getBoolean(Shared.PARAM_ALLOW_DEBUG_OK_SSO);
    ssoAuthorizationStarted = bundle.getBoolean(SSO_STARTED, false);

    if (!ssoAuthorizationStarted) {
        auth();
    }
}
 
开发者ID:odnoklassniki,项目名称:ok-android-sdk,代码行数:23,代码来源:OkAuthActivity.java

示例3: auth

import ru.ok.android.sdk.util.OkAuthType; //导入依赖的package包/类
private void auth() {
    if (!hasAppInfo()) {
        onFail(getString(R.string.no_application_data));
        return;
    }

    if ((authType == OkAuthType.NATIVE_SSO) || (authType == OkAuthType.ANY)) {
        if (startSsoAuthorization()) {
            ssoAuthorizationStarted = true;
            return;
        } else if (authType == OkAuthType.NATIVE_SSO) {
            onFail(getString(R.string.no_ok_application_installed));
            return;
        }
    }

    if ((authType == OkAuthType.WEBVIEW_OAUTH) || (authType == OkAuthType.ANY)) {
        mWebView.loadUrl(buildOAuthUrl());
    }
}
 
开发者ID:odnoklassniki,项目名称:ok-android-sdk,代码行数:21,代码来源:OkAuthActivity.java

示例4: requestAuthorization

import ru.ok.android.sdk.util.OkAuthType; //导入依赖的package包/类
/**
 * Starts user authorization
 *
 * @param redirectUri the URI to which the access_token will be redirected
 * @param authType    selected auth type
 * @param scopes      {@link OkScope} - application request permissions as per {@link OkScope}.
 * @see OkAuthType
 */
public final void requestAuthorization(Activity activity, @Nullable String redirectUri,
                                       OkAuthType authType, final String... scopes) {
    final Intent intent = new Intent(activity, OkAuthActivity.class);
    intent.putExtra(Shared.PARAM_CLIENT_ID, mAppId);
    intent.putExtra(Shared.PARAM_APP_KEY, mAppKey);
    intent.putExtra(Shared.PARAM_REDIRECT_URI, redirectUri);
    intent.putExtra(Shared.PARAM_AUTH_TYPE, authType);
    intent.putExtra(Shared.PARAM_SCOPES, scopes);
    intent.putExtra(Shared.PARAM_ALLOW_DEBUG_OK_SSO, allowDebugOkSso);
    activity.startActivityForResult(intent, Shared.OK_AUTH_REQUEST_CODE);
}
 
开发者ID:odnoklassniki,项目名称:ok-android-sdk,代码行数:20,代码来源:Odnoklassniki.java

示例5: LoginClickListener

import ru.ok.android.sdk.util.OkAuthType; //导入依赖的package包/类
public LoginClickListener(OkAuthType authType) {
    this.authType = authType;
}
 
开发者ID:odnoklassniki,项目名称:ok-android-sdk,代码行数:4,代码来源:MainActivity.java

示例6: login

import ru.ok.android.sdk.util.OkAuthType; //导入依赖的package包/类
private boolean login(final JSONArray permissions, final CallbackContext context) 
{
    final SocialOk self = this;
    lastLoginPermissions = permissions;
    odnoklassnikiObject.checkValidTokens(new OkListener() {
            @Override
            public void onSuccess(JSONObject json) {
                //Log.i(TAG, "Token valid: "+json.toString());
                final String token = json.optString("access_token");
                final String uid = json.optString("logged_in_user");
                final String sessionSecretKey = json.optString("session_secret_key");
                Log.i(TAG, "Odnoklassniki accessToken = " + token);
                afterLogin(token, uid, sessionSecretKey, context);
            }
            @Override
            public void onError(String error) {
                //Toast.makeText(MainActivity.this, String.format("%s: %s", getString(R.string.error), error), Toast.LENGTH_LONG).show();
                Log.e(TAG, "Token invalid. "+ error);
                odnoklassnikiObject.clearTokens();
                //login(lastLoginPermissions, _callbackContext);
                //вызываем запрос авторизации. После OAuth будет вызван callback, определенный для объекта
                String[] perm;
                if(permissions != null && permissions.length() > 0) {
                    perm = new String[permissions.length()];
                    for(int i=0; i<permissions.length(); i++) {
                        perm[i] = permissions.optString(i, "");
                    }
                } else {
                    perm = new String[1];
                    perm[0] = OkScope.VALUABLE_ACCESS;
                }
                self._callbackContext = context;
                OkAuthType authType = OkAuthType.ANY;
                odnoklassnikiObject.requestAuthorization(getActivity(), REDIRECT_URL, authType, perm);
                /*
                final Intent intent = new Intent(getActivity(), OkAuthActivity.class);
                intent.putExtra(Shared.PARAM_CLIENT_ID, mAppId);
                intent.putExtra(Shared.PARAM_APP_KEY, mAppKey);
                intent.putExtra(Shared.PARAM_REDIRECT_URI, REDIRECT_URL);
                intent.putExtra(Shared.PARAM_AUTH_TYPE, authType);
                intent.putExtra(Shared.PARAM_SCOPES, perm);
                cordova.startActivityForResult(self, intent, Shared.OK_AUTH_REQUEST_CODE);
                */
                Log.i(TAG, "Login requested with permissions:" + perm.toString());
                self.cordova.setActivityResultCallback(self);
            }
        });

    return true;
}
 
开发者ID:DrMoriarty,项目名称:cordova-social-ok,代码行数:51,代码来源:SocialOk.java


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