/// <summary> /// Token request object initilization to retreive user information /// </summary> /// <param name="accessToken"></param> /// <returns></returns> public object GetTokenInfo(string accessToken) { Oauth2Service.TokeninfoRequest tokeninfoRequest = new Oauth2Service().Tokeninfo(); Google.Apis.Discovery.Parameter accessType = new Google.Apis.Discovery.Parameter { DefaultValue = GoogleReqestParameters.offline.ToString(), Name = GoogleReqestParameters.access_type.ToString() }; tokeninfoRequest.RequestParameters.Add("AccessType", accessType); tokeninfoRequest.AccessToken = accessToken; Tokeninfo tokeninfo = tokeninfoRequest.Execute(); return(tokeninfo); }
/// <summary> /// Is token expired or not /// </summary> /// <param name="accessToken"></param> /// <returns></returns> public bool IsTokenExpired(string accessToken) { Tokeninfo tokeninfo = null; Oauth2Service.TokeninfoRequest tokeninfoRequest = new Oauth2Service().Tokeninfo(); Google.Apis.Discovery.Parameter accessType = new Google.Apis.Discovery.Parameter { DefaultValue = GoogleReqestParameters.offline.ToString(), Name = GoogleReqestParameters.access_type.ToString() }; tokeninfoRequest.RequestParameters.Add("AccessType", accessType); tokeninfoRequest.AccessToken = accessToken; try { tokeninfo = tokeninfoRequest.Execute(); } catch (Exception) { // ignored } return(tokeninfo == null); }