how to know that user accept oauth permission in youtube api v2 in android -
i want use youtube api v2 in android, following developers.google.com/youtube when open https://accounts.google.com/o/oauth2/auth?client_id=client_id&redirect_uri=redirect_uri&scope=https://gdata.youtube.com&response_type=code
url in webview, ask access application. how know if user accept it, because after accepting webview redirect page can success code=4/fsgko348949
i think tutorial can useful:
http://blog.blundell-apps.com/tut-oauth-youtube-api-access/
this tutorial shows how detect if user selects “allow access” using listener:
package com.blundell.youtubesignin.oauth; /** * class checks paramater's our redirect url has informing our listener * passes auth code if access granted. * * google documentation: * if user granted access application, * google have appended code parameter redirect_uri. * value temporary authorization code can exchange access token. * example : http://localhost/oauth2callback?code=4/ux5gnj-_miu4dod_gnzdjx9etoff * * if user refused grant access application, * google have included access_denied error message in hash fragment of redirect_uri. * example : http://localhost/oauth2callback#error=access_denied * * @author paul.blundell * */ public class paramchecker implements onoauthcallbacklistener { private final onoauthlistener onoauth; public paramchecker(onoauthlistener onoauth) { this.onoauth = onoauth; } @override public void onoauthcallback(string params) { if(params.contains("access_denied")){ // user said no onoauth.onrefused(); } else { // user auth'd string authcode = extractauthcode(params); onoauth.onauthorized(authcode); } } private static string extractauthcode(string params) { return params.substring(constants.auth_code_param.length()+1); } }