Coder Social home page Coder Social logo

VkClient return error about oauth2 HOT 5 OPEN

Alxdhere avatar Alxdhere commented on September 28, 2024
VkClient return error

from oauth2.

Comments (5)

niemyjski avatar niemyjski commented on September 28, 2024

Can you please submit a pr

from oauth2.

Alxdhere avatar Alxdhere commented on September 28, 2024

Excuse me, what is "pr"?

from oauth2.

niemyjski avatar niemyjski commented on September 28, 2024

Pull request, also do you have any documentation for the supported versions and api changes?

from oauth2.

Alxdhere avatar Alxdhere commented on September 28, 2024

I don't have documentation.
I tried to get information about the user using VkClient in the same way as I received information using GoogleClient. But there was an exception.
Then I decided to make requests to the api myself:

    UriBuilder accessUriBuilder = new UriBuilder("https://oauth.vk.com/access_token");
    NameValueCollection accessQueries = HttpUtility.ParseQueryString(accessUriBuilder.Query);
    accessQueries["client_id"] = provider.ClientId;
    accessQueries["client_secret"] = provider.SecretKey;
    accessQueries["redirect_uri"] = redirect.ToString();
    accessQueries["grant_type"] = "authorization_code";
    accessQueries["code"] = code;
    accessUriBuilder.Query = accessQueries.ToString();

    HttpClient httpClient = new HttpClient();
    var accessResponseValue = await httpClient
        .GetStringAsync(accessUriBuilder.Uri.ToString())
        .ConfigureAwait(false);

    var accessResponse = JObject.Parse(accessResponseValue);
    string access_token = accessResponse.GetValue("access_token").Value<string>();
    string user_id = accessResponse.GetValue("user_id").Value<string>();
    string email = accessResponse.GetValue("email").Value<string>();
    
    UriBuilder userInfoUriBuilder = new UriBuilder("https://api.vk.com/method/users.get");
    NameValueCollection userInfoQueries = HttpUtility.ParseQueryString(userInfoUriBuilder.Query);
    userInfoQueries["v"] = "5.74";
    userInfoQueries["access_token"] = access_token;
    userInfoQueries["user_ids"] = user_id;
    userInfoQueries["fields"] = "first_name,last_name,has_photo,photo_max_orig,sex,bdate,phone";
    userInfoUriBuilder.Query = userInfoQueries.ToString();
    
    var userInfoResponseValue = await httpClient
        .GetStringAsync(userInfoUriBuilder.Uri.ToString())
        .ConfigureAwait(false);
    var userInfoResponse = JObject.Parse(userInfoResponseValue);

As a result, I received an error message:
Invalid request: versions below 5.81 are deprecated. Version param should be passed as "v". "version" param is invalid and not supported. For more information go to https://vk.com/dev/constant_version_updates

Fixed 5.74 to 5.81 and it worked! (5.131 is actual)

from oauth2.

niemyjski avatar niemyjski commented on September 28, 2024

Thanks for that, if you want to submit a pull request to change the version that would be greatly appreciated.

from oauth2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.