/// <summary> /// Called just before issuing request to third-party service when everything is ready. /// Allows to add extra parameters to request or do any other needed preparations. /// </summary> protected override void BeforeGetUserInfo(BeforeAfterRequestArgs args) { // Source document // http://dev.odnoklassniki.ru/wiki/pages/viewpage.action?pageId=12878032 args.Request.AddParameter("application_key", _configuration.ClientPublic); args.Request.AddParameter("method", "users.getCurrentUser"); // workaround for current design, oauth_token is always present in URL, so we need emulate it for correct request signing var fakeParam = new Parameter() { Name = "oauth_token", Value = AccessToken }; args.Request.AddParameter(fakeParam); // Signing. // Call API methods using access_token instead of session_key parameter // Calculate every request signature parameter sig using a little bit different way described in // http://dev.odnoklassniki.ru/wiki/display/ok/Authentication+and+Authorization // sig = md5( request_params_composed_string+ md5(access_token + application_secret_key) ) // Don't include access_token into request_params_composed_string string signature = string.Concat(args.Request.Parameters.OrderBy(x => x.Name).Select(x => string.Format("{0}={1}", x.Name, x.Value)).ToList()); signature = (signature + (AccessToken + _configuration.ClientSecret).GetMd5Hash()).GetMd5Hash(); // Removing fake param to prevent dups args.Request.Parameters.Remove(fakeParam); args.Request.AddParameter("access_token", AccessToken); args.Request.AddParameter("sig", signature); }
/// <summary> /// Called just after obtaining response with access token from service. /// Allows to read extra data returned along with access token. /// </summary> protected override void AfterGetAccessToken(BeforeAfterRequestArgs args) { // Instagram returns userinfo on access_token request // Source document // http://instagram.com/developer/authentication/ _accessTokenResponseContent = args.Response.GetContent(); }
/// <summary> /// Called just before issuing request to third-party service when everything is ready. /// Allows to add extra parameters to request or do any other needed preparations. /// </summary> protected override void BeforeGetUserInfo(BeforeAfterRequestArgs args) { // Source documents // https://developer.foursquare.com/overview/auth.html // https://developer.foursquare.com/overview/versioning args.Request.AddParameter("v", System.DateTime.Now.ToString("yyyyMMdd")); }
/// <summary> /// Called just after obtaining response with access token from third-party service. /// Allows to read extra data returned along with access token. /// </summary> protected override void AfterGetAccessToken(BeforeAfterRequestArgs args) { var instance = JObject.Parse(args.Response.Content); _userId = instance["user_id"].Value<string>(); var email = instance["email"]; if (email != null) _email = email.Value<string>(); }
protected override void BeforeGetUserInfo(BeforeAfterRequestArgs args) { args.Client.Authenticator = null; args.Request.Parameters.Add(new Parameter { Name = "oauth2_access_token", Type = ParameterType.GetOrPost, Value = AccessToken }); }
protected override void BeforeGetAccessToken(BeforeAfterRequestArgs args) { args.Request.AddObject(new { code = args.Parameters.GetOrThrowUnexpectedResponse("code"), client_id = args.Configuration.ClientId, client_secret = args.Configuration.ClientSecret, redirect_uri = args.Configuration.RedirectUri, state = State, }); }
/// <summary> /// Called just before issuing request to third-party service when everything is ready. /// Allows to add extra parameters to request or do any other needed preparations. /// </summary> protected override void BeforeGetUserInfo(BeforeAfterRequestArgs args) { // Source documents // http://api.mail.ru/docs/guides/restapi/ // http://api.mail.ru/docs/reference/rest/users.getInfo/ args.Request.AddOrUpdateParameter("app_id", _configuration.ClientId); args.Request.AddOrUpdateParameter("method", "users.getInfo"); args.Request.AddOrUpdateParameter("secure", "1"); args.Request.AddOrUpdateParameter("session_key", AccessToken); // workaround for current design, oauth_token is always present in URL, so we need emulate it for correct request signing var fakeParam = new Parameter { Name = "oauth_token", Value = AccessToken }; args.Request.AddParameter(fakeParam); //sign=hex_md5('app_id={client_id}method=users.getInfosecure=1session_key={access_token}{secret_key}') string signature = string.Concat(args.Request.Parameters.OrderBy(x => x.Name).Select(x => string.Format("{0}={1}", x.Name, x.Value)).ToList()); signature = (signature+_configuration.ClientSecret).GetMd5Hash(); args.Request.Parameters.Remove(fakeParam); args.Request.AddOrUpdateParameter("sig", signature); }
/// <summary> /// Called just after obtaining response with access token from service. /// Allows to read extra data returned along with access token. /// </summary> protected override void AfterGetAccessToken(BeforeAfterRequestArgs args) { _accessUserInfo = args.Response.GetContent(); }
protected override void BeforeGetUserInfo(BeforeAfterRequestArgs args) { args.Client.Authenticator = null; args.Request.Parameters.Add(new Parameter { Name = "token", Type = ParameterType.GetOrPost, Value = AccessToken }); args.Request.AddParameter("resource_types", "[\"all\"]"); base.BeforeGetUserInfo(args); }
/// <summary> /// Called just before issuing request to third-party service when everything is ready. /// Allows to add extra parameters to request or do any other needed preparations. /// </summary> protected override void BeforeGetUserInfo(BeforeAfterRequestArgs args) { // Source document // http://api.yandex.com/oauth/doc/dg/yandex-oauth-dg.pdf }
/// <summary> /// It's required to store the User GUID obtained in the response for further usage /// https://developer.yahoo.com/oauth2/guide/flows_authcode/ /// </summary> /// <param name="args"></param> protected override void AfterGetAccessToken(BeforeAfterRequestArgs args) { var responseJObject = JObject.Parse(args.Response.Content); this._userProfileGUID = responseJObject.SelectToken("xoauth_yahoo_guid")?.ToString(); }
/// <summary> /// Called just after obtaining response with access token from third-party service. /// Allows to read extra data returned along with access token. /// </summary> protected override void AfterGetAccessToken(BeforeAfterRequestArgs args) { var instance = JObject.Parse(args.Response.Content); _userId = instance["user_id"].Value<string>(); }
/// <summary> /// Called just before issuing request to third-party service when everything is ready. /// Allows to add extra parameters to request or do any other needed preparations. /// </summary> protected override void BeforeGetUserInfo(BeforeAfterRequestArgs args) { args.Request.AddParameter("access_token", AccessToken); }
/// <summary> /// Called just before issuing request to third-party service when everything is ready. /// Allows to add extra parameters to request or do any other needed preparations. /// </summary> protected override void BeforeGetUserInfo(BeforeAfterRequestArgs args) { args.Request.AddHeader("Authorization", "Bearer " + AccessToken); }
/// <summary> /// Called just before issuing request to third-party service when everything is ready. /// Allows to add extra parameters to request or do any other needed preparations. /// </summary> protected override void BeforeGetUserInfo(BeforeAfterRequestArgs args) { args.Request.AddParameter("fields", "id,first_name,last_name,email,picture"); }
protected override void BeforeGetAccessToken(BeforeAfterRequestArgs args) { var grantType = args.Parameters["grant_type"]; if (string.IsNullOrWhiteSpace(grantType)) { base.BeforeGetAccessToken(args); } else if (grantType == RefreshTokenKey) { args.Request.AddObject(new { refresh_token = args.Parameters.GetOrThrowUnexpectedResponse(RefreshTokenKey), client_id = Configuration.ClientId, client_secret = Configuration.ClientSecret, grant_type = RefreshTokenKey }); } }
protected override void AfterGetAccessToken(BeforeAfterRequestArgs args) { base.AfterGetAccessToken(args); //receiving args.Response & args.Parameters UserId = ParseTokenResponse(args.Response.Content, "user_id"); }
/// <summary> /// Called just before building the request URI when everything is ready. /// Allows to add extra parameters to request or do any other needed preparations. /// </summary> protected override async Task BeforeGetLoginLinkUri(BeforeAfterRequestArgs args) { await base.BeforeGetLoginLinkUri(args); // This allows us to get a refresh token args.Request.AddParameter("access_type", "offline"); }
protected override void BeforeGetAccessToken(BeforeAfterRequestArgs args) { args.Client.Authenticator = new HttpBasicAuthenticator(Configuration.ClientId, Configuration.ClientSecret); base.BeforeGetAccessToken(args); }
protected override void BeforeGetUserInfo(BeforeAfterRequestArgs args) { args.Request.AddParameter("fields", "id,first_name,last_name,email,picture,gender,location,age_range,birthday"); }
protected override void BeforeGetUserInfo(BeforeAfterRequestArgs args) { args.Client.Authenticator = new OAuth2AuthorizationRequestHeaderAuthenticator(AccessToken, "Bearer"); base.BeforeGetUserInfo(args); }
protected override void AfterGetAccessToken(BeforeAfterRequestArgs args) { _accessToken = args.Response.Content; }
/// <summary> /// Called just before issuing request to third-party service when everything is ready. /// Allows to add extra parameters to request or do any other needed preparations. /// </summary> protected override void BeforeGetUserInfo(BeforeAfterRequestArgs args) { args.Request.AddParameter("opt_fields", "id,name,photo.image_128x128,photo.image_60x60,photo.image_36x36,email"); args.Client.Authenticator = new OAuth2AuthorizationRequestHeaderAuthenticator(AccessToken, "Bearer"); }
/// <summary> /// Called just before issuing request to third-party service when everything is ready. /// Allows to add extra parameters to request or do any other needed preparations. /// </summary> protected override void BeforeGetUserInfo(BeforeAfterRequestArgs args) { // workaround for current design, oauth_token is always present in URL, so we need emulate it for correct request signing var accessToken = new Parameter { Name = "access_token", Value = AccessToken }; args.Request.AddParameter(accessToken); }
/// <summary> /// Called just before issuing request to third-party service when everything is ready. /// Allows to add extra parameters to request or do any other needed preparations. /// </summary> protected override void BeforeGetUserInfo(BeforeAfterRequestArgs args) { args.Request.AddParameter("uids", _userId); args.Request.AddParameter("fields", "uid,first_name,last_name,photo"); }
protected override void AfterGetAccessToken(BeforeAfterRequestArgs args) { string token; try { // response can be sent in JSON format token = (string)JObject.Parse(args.Response.Content).SelectToken(RefreshTokenKey); } catch (JsonReaderException) { // or it can be in "query string" format (param1=val1¶m2=val2) var collection = HttpUtility.ParseQueryString(args.Response.Content); token = collection[RefreshTokenKey]; } if (!string.IsNullOrWhiteSpace(token)) { RefreshToken = token; } base.AfterGetAccessToken(args); }
/// <summary> /// Called just before issuing request to third-party service when everything is ready. /// Allows to add extra parameters to request or do any other needed preparations. /// </summary> protected override void BeforeGetUserInfo(BeforeAfterRequestArgs args) { args.Client.Authenticator = new OAuth2AuthorizationRequestHeaderAuthenticator(AccessToken, "Bearer"); }
/// <summary> /// Called just before issuing request to third-party service when everything is ready. /// Allows to add extra parameters to request or do any other needed preparations. /// /// We have to reformat the Url adding the user guid for accessing their information /// https://developer.yahoo.com/oauth2/guide/apirequests/ /// </summary> protected override void BeforeGetUserInfo(BeforeAfterRequestArgs args) { args.Client.Authenticator = new OAuth2AuthorizationRequestHeaderAuthenticator(AccessToken, "Bearer"); args.Request.Resource = string.Format(this.UserInfoServiceEndpoint.Resource, this._userProfileGUID); }