Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static final String CLIENT_ID = "seu_id";
- public static final String CLIENT_SECRET = "seu_secret";
- public static final String CALLBACK_URL = "callback";
- String url ="https://instagram.com/oauth/authorize?" +"response_type=token" + "&redirect_uri=" + CALLBACK_URL+"&scope=basic"+"&client_id=" + CLIENT_ID ;
- WebView webview;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.photo_activity);
- ActionBar bar = getActionBar();
- bar.setDisplayHomeAsUpEnabled(true);
- WebView webview = (WebView)findViewById(R.id.webView2);
- webview.setWebViewClient(new WebViewClient() {
- public void onPageStarted(WebView view, String url, Bitmap favicon) {
- String fragment = "#access_token=";
- int start = url.indexOf(fragment);
- if (start > -1) {
- // You can use the accessToken for api calls now.
- String accessToken = url.substring(start + fragment.length(), url.length());
- Log.v(TAG, "OAuth complete, token: [" + accessToken + "].");
- Log.i(TAG, "" +accessToken);
- Toast.makeText(PhotosActivity.this, "Token: " + accessToken, Toast.LENGTH_SHORT).show();
- }
- }
- });
- webview.loadUrl(url);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement