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


Java AuthenticationClient类代码示例

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


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

示例1: authenticate

import com.spotify.sdk.android.authentication.AuthenticationClient; //导入依赖的package包/类
boolean authenticate() {
  //Log.d("DEBUG", "SPOTIFY:: authenticate " + getRedirectUri().toString());

  if (isNetworkEnable && !isAuthenticated && getSavedValue("SPOTIFY_USE", false)) {
    AuthenticationRequest.Builder builder = new Builder(getString(R.string.spotify_client_id),
        Type.TOKEN,
        "jins-meme-bridge-login://callback");
    builder.setShowDialog(false).setScopes(
        new String[]{"user-read-private", "playlist-read", "playlist-read-private",
            "user-follow-read", "user-library-read", "streaming"});
    final AuthenticationRequest request = builder.build();

    AuthenticationClient.openLoginActivity(this, REQUEST_CODE, request);

    return false;
  } else {
    return true;
  }
}
 
开发者ID:tkrworks,项目名称:JinsMemeBRIDGE-Android,代码行数:20,代码来源:MainActivity.java

示例2: processRequestToken

import com.spotify.sdk.android.authentication.AuthenticationClient; //导入依赖的package包/类
String processRequestToken(int requestCode, int resultCode, Intent data) {
  if (requestCode == REQUEST_CODE) {
    final AuthenticationResponse response = AuthenticationClient.getResponse(resultCode, data);

    SpotifyConfigFragment.setAccessToken(response.getAccessToken());

    switch (response.getType()) {
      case TOKEN:
        Log.d("DEBUG", "Spotify Token: " + response.getAccessToken());

        onAuthenticationComplete(response, getString(R.string.spotify_client_id));
        SpotifyConfigFragment.setIsLoggedIn(true);
        break;
      case ERROR:
        Log.d("DEBUG", "Spotify Error: " + response.getError());
        break;
      default:
        Log.d("DEBUG", "Spotify Other: " + response.getState());
        break;
    }
  }

  return SpotifyConfigFragment.getAccessToken();
}
 
开发者ID:tkrworks,项目名称:JinsMemeBRIDGE-Android,代码行数:25,代码来源:MainActivity.java

示例3: onCreate

import com.spotify.sdk.android.authentication.AuthenticationClient; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_authentication);
    ((Injector) getApplication()).inject(this);
    overridePendingTransition(R.anim.short_fade_in, R.anim.short_fade_out);

    AuthenticationRequest authRequest = new AuthenticationRequest.Builder(
        BuildConfig.SPOTIFY_CLIENT_ID,
        AuthenticationResponse.Type.TOKEN,
        SpotifyConstants.REDIRECT_URI)
        .setScopes(SpotifyConstants.DEFAULT_USER_SCOPES)
        .build();

    AuthenticationClient.openLoginActivity(this,
        ApplicationConstants.LOGIN_INTENT_REQUEST_CODE,
        authRequest);
}
 
开发者ID:ZinoKader,项目名称:SpotiQ,代码行数:19,代码来源:SpotifyAuthenticationActivity.java

示例4: onActivityResult

import com.spotify.sdk.android.authentication.AuthenticationClient; //导入依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
    super.onActivityResult(requestCode, resultCode, intent);

    // Check if result comes from the correct activity
    if (requestCode == REQUEST_CODE) {
        AuthenticationResponse response = AuthenticationClient.getResponse(resultCode, intent);
        if (response.getType() == AuthenticationResponse.Type.TOKEN) {
            // TODO progress dialog
            SpotifyTvApplication.getInstance().startSpotifySession(MainActivity.this, response.getAccessToken(), new Runnable() {
                @Override
                public void run() {
                    init();
                }
            }, new Runnable() {
                @Override
                public void run() {
                    showError();
                }
            });
        } else {
            showError();
        }
    }
}
 
开发者ID:sregg,项目名称:spotify-tv,代码行数:26,代码来源:MainActivity.java

示例5: onActivityResult

import com.spotify.sdk.android.authentication.AuthenticationClient; //导入依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    // If logged into Spotify, retrieve an access code to make requests
    if (requestCode == LOGIN_REQUEST_CODE) {
        AuthenticationResponse response = AuthenticationClient
                .getResponse(LOGIN_REQUEST_CODE, data);
        switch (response.getType()){
            // If received token
            case TOKEN:
                SpotifyManager.ACCESS_TOKEN = response.getAccessToken();
                Log.wtf(TAG, "Got access token");
                mSongDataFragment.notifySongDataAdapter();
                break;
            case ERROR:
                SpotifyManager.ACCESS_TOKEN = SpotifyManager.NULL_ACCESS_TOKEN;
                Log.wtf(TAG, "ERROR retrieving access token");
                break;
            case EMPTY:
                SpotifyManager.ACCESS_TOKEN = SpotifyManager.NULL_ACCESS_TOKEN;
                Log.wtf(TAG, "EMPTY access token");
                break;
            default:
                SpotifyManager.ACCESS_TOKEN = SpotifyManager.NULL_ACCESS_TOKEN;
                Log.wtf(TAG, "Could not retrieve access token");
                break;
        }
    }
}
 
开发者ID:AkshayPall,项目名称:Songify,代码行数:30,代码来源:MainActivity.java

示例6: authenticateSpotify

import com.spotify.sdk.android.authentication.AuthenticationClient; //导入依赖的package包/类
/**
     * Used to get access token to make any calls to the Spotify Api
     * @param callingActivity
     */
    public static void authenticateSpotify (Activity callingActivity){
        AuthenticationRequest.Builder builder = new AuthenticationRequest.Builder(
                callingActivity.getResources().getString(R.string.spotify_client_id),
                AuthenticationResponse.Type.TOKEN,
                callingActivity.getResources().getString(R.string.spotify_redirect_uri)
        );
//        builder.setScopes(new String[]{"streaming"});
        AuthenticationRequest request = builder.build();
        AuthenticationClient.openLoginActivity(
                callingActivity,
                LOGIN_REQUEST_CODE,
                request
        );
    }
 
开发者ID:AkshayPall,项目名称:Songify,代码行数:19,代码来源:SpotifyManager.java

示例7: onCreate

import com.spotify.sdk.android.authentication.AuthenticationClient; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    ButterKnife.bind(this);

    AuthenticationRequest.Builder builder =
            new AuthenticationRequest.Builder(
                    CLIENT_ID,
                    AuthenticationResponse.Type.TOKEN,
                    REDIRECT_URI);

    builder.setScopes(SpotifyAuthorizationScopes.FULL_ACCESS_SCOPES);
    AuthenticationRequest request = builder.build();

    Log.e("STARTUP", "SPOTIFY TOKEN: " + Utils.getStringFromSharedPreferences(this, R.string.sharedpreferences_global, getString(R.string.spotifyAccessToken_value)));
    Log.e("STARTUP", "SPOTIFY EXPIRY: " + Utils.getSharedPreferences(this, R.string.sharedpreferences_global).getInt(getString(R.string.spotifyAccessToken_expiration), -1));

    Snackbar.make(
            getWindow().getDecorView().getRootView(),
            Utils.checkInternetConnectionString(this),
            Snackbar.LENGTH_LONG
    ).show();

    connectionStateCallback = this;
    AuthenticationClient.openLoginActivity(this, REQUEST_CODE, request);

    buildRecycler();
}
 
开发者ID:sharaquss,项目名称:Betterfy,代码行数:30,代码来源:MainActivity.java

示例8: onActivityResult

import com.spotify.sdk.android.authentication.AuthenticationClient; //导入依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    final AuthenticationResponse response = AuthenticationClient.getResponse(resultCode, data);

    if (AUTH_TOKEN_REQUEST_CODE == requestCode) {
        mAccessToken = response.getAccessToken();
        updateTokenView();
    } else if (AUTH_CODE_REQUEST_CODE == requestCode) {
        mAccessCode = response.getCode();
        updateCodeView();
    }
}
 
开发者ID:spotify,项目名称:android-auth,代码行数:14,代码来源:MainActivity.java

示例9: login

import com.spotify.sdk.android.authentication.AuthenticationClient; //导入依赖的package包/类
private void login(JSONArray scopes, Boolean fetchTokenManually) {
    AuthenticationResponse.Type authType = fetchTokenManually ? AuthenticationResponse.Type.CODE :AuthenticationResponse.Type.TOKEN;


    AuthenticationRequest.Builder builder = new AuthenticationRequest.Builder(clientId,
            authType,
            redirectUri);
    builder.setScopes(new String[]{"user-read-private", "streaming"});
    builder.setShowDialog(true);
    AuthenticationRequest request = builder.build();

    Log.d(TAG, "Client ID " + clientId + "AUTH RESPONSE TYPE " + AuthenticationResponse.Type.TOKEN + "REDIRECT URI " + redirectUri + " Scopes " + scopes + " manual " + fetchTokenManually);

    AuthenticationClient.openLoginActivity(cordova.getActivity(), REQUEST_CODE, request);
}
 
开发者ID:pmwisdom,项目名称:cordova-spotify-plugin,代码行数:16,代码来源:CDVSpotify.java

示例10: logout

import com.spotify.sdk.android.authentication.AuthenticationClient; //导入依赖的package包/类
private void logout() {
    AuthenticationClient.clearCookies(cordova.getActivity());

    this.clearPlayerState();
    isLoggedIn = false;
    currentAccessToken = null;
}
 
开发者ID:pmwisdom,项目名称:cordova-spotify-plugin,代码行数:8,代码来源:CDVSpotify.java

示例11: openRequest

import com.spotify.sdk.android.authentication.AuthenticationClient; //导入依赖的package包/类
private void openRequest() {
    AuthenticationRequest.Builder builder = new AuthenticationRequest.Builder(pasta.CLIENT_ID, AuthenticationResponse.Type.TOKEN, REDIRECT_URI);
    builder.setScopes(new String[]{"user-read-private", "user-read-email", "streaming", "user-follow-read", "user-follow-modify", "user-library-read", "playlist-read-private", "playlist-modify-public", "playlist-modify-private"});
    AuthenticationRequest request = builder.build();

    AuthenticationClient.openLoginActivity(this, REQUEST_CODE, request);
}
 
开发者ID:TheAndroidMaster,项目名称:Pasta-for-Spotify,代码行数:8,代码来源:MainActivity.java

示例12: login

import com.spotify.sdk.android.authentication.AuthenticationClient; //导入依赖的package包/类
private void login() {
    String clientId = getString(R.string.spotify_client_id);
    String[] scopes = getResources().getStringArray(R.array.spotify_scopes);
    String redirectUri = getString(R.string.spotify_callback_uri_scheme)
            + "://" + getString(R.string.spotify_callback_uri_host);

    AuthenticationRequest.Builder builder = new AuthenticationRequest.Builder(clientId,
            AuthenticationResponse.Type.TOKEN,
            redirectUri);
    builder.setScopes(scopes);
    AuthenticationRequest request = builder.build();

    AuthenticationClient.openLoginActivity(this, REQUEST_CODE, request);
}
 
开发者ID:sregg,项目名称:spotify-tv,代码行数:15,代码来源:MainActivity.java

示例13: onRequestCodeClicked

import com.spotify.sdk.android.authentication.AuthenticationClient; //导入依赖的package包/类
public void onRequestCodeClicked(View view) {
    final AuthenticationRequest request = getAuthenticationRequest(AuthenticationResponse.Type.CODE);
    AuthenticationClient.openLoginActivity(this, AUTH_CODE_REQUEST_CODE, request);
}
 
开发者ID:spotify,项目名称:android-auth,代码行数:5,代码来源:MainActivity.java

示例14: onRequestTokenClicked

import com.spotify.sdk.android.authentication.AuthenticationClient; //导入依赖的package包/类
public void onRequestTokenClicked(View view) {
    final AuthenticationRequest request = getAuthenticationRequest(AuthenticationResponse.Type.TOKEN);
    AuthenticationClient.openLoginActivity(this, AUTH_TOKEN_REQUEST_CODE, request);
}
 
开发者ID:spotify,项目名称:android-auth,代码行数:5,代码来源:MainActivity.java

示例15: onCreate

import com.spotify.sdk.android.authentication.AuthenticationClient; //导入依赖的package包/类
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getWindow().requestFeature(Window.FEATURE_ACTION_BAR);
        ActionBar actionBar = getSupportActionBar();

        actionBar.setTitle(Html.fromHtml("<font color='#111111'>Matchify</font>"));

        setContentView(R.layout.activity_home);


        //Requesting permissions
        if (Build.VERSION.SDK_INT >= 23 && (PackageManager.PERMISSION_GRANTED != checkSelfPermission(Manifest.permission.READ_SMS) ||
                PackageManager.PERMISSION_GRANTED != checkSelfPermission(Manifest.permission.READ_PHONE_STATE))) {
            requestPermissions(INITIAL_PERMS, INITIAL_REQUEST);
        }

        tm = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);


        matchButton = (Button) findViewById(R.id.beginMatching);
//        settingsButton = (Button) findViewById(R.id.settingsButton);

        matchButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (me != null) {
                    Intent matchIntent = new Intent(HomeActivity.this, MatchActivity.class);
                    matchIntent.putExtra("userId", me.id);
                    startActivity(matchIntent);
                } else {
                    Toast.makeText(getApplicationContext(), "Please wait: connecting to Spotify servers...",
                            Toast.LENGTH_SHORT).show();
                }
            }
        });

//        settingsButton.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                Intent playIntent = new Intent(HomeActivity.this, SettingsActivity.class);
//                startActivity(playIntent);
//            }
//        });

        AuthenticationRequest.Builder builder = new AuthenticationRequest.Builder(CLIENT_ID,
                AuthenticationResponse.Type.TOKEN,
                REDIRECT_URI);

        builder.setScopes(new String[]{"user-read-private", "user-read-email", "streaming", "user-top-read"});
        AuthenticationRequest request = builder.build();

        AuthenticationClient.openLoginActivity(this, REQUEST_CODE, request);


    }
 
开发者ID:debkbanerji,项目名称:matchify,代码行数:57,代码来源:HomeActivity.java


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