private static dynamic RetrieveUserInfo(string accessToken) { var uri = OAuthHelpers.BuildUri(ApiUrl, "oauth2/v1/userinfo", new NameValueCollection { { "access_token", accessToken } }); var response = OAuthHelpers.GetObjectFromAddress(uri); return(response); }
private string BuildAuthUri(string returnUrl) { var appId = GetAppId(); var returnUriValue = BuildCallbackUriValue(); var authUri = OAuthHelpers.BuildUri(OAuthUrl, "o/oauth2/auth", new NameValueCollection() { { "client_id", appId }, { "redirect_uri", returnUriValue }, { "response_type", "code" }, { "scope", "email" }, { "state", HttpUtility.UrlEncode(returnUrl) } }); return(authUri); }
private string RetrieveAccessToken(string authorizationCode) { var appId = GetAppId(); var appSecret = GetAppSecret(); var returnUriValue = BuildCallbackUriValue(); var param = new NameValueCollection { { "client_id", appId }, { "client_secret", appSecret }, { "code", authorizationCode }, { "grant_type", "authorization_code" }, { "redirect_uri", returnUriValue }, }; var url = OAuthHelpers.BuildUri(OAuthUrl, "o/oauth2/token", new NameValueCollection()); string accessToken = OAuthHelpers.GetObjectWithPost(url, param).access_token; return(accessToken); }