示例#1
0
        private static void GetOAuth2TokenCallbackImpl(IntPtr ptr, Result result, ref OAuth2Token oauth2Token)
        {
            GCHandle h = GCHandle.FromIntPtr(ptr);
            GetOAuth2TokenHandler callback = (GetOAuth2TokenHandler)h.Target;

            h.Free();
            callback(result, ref oauth2Token);
        }
示例#2
0
        /// <summary>
        ///     Retrieve an oauth2 bearer token for the current user. If your game was launched from Discord and you call this
        ///     function, you will automatically receive the token.
        ///     If the game was not launched from Discord and this method is called, Discord will focus itself and prompt the user
        ///     for authorization.
        ///     <para>
        ///         Ensure that you have <c>http://127.0.0.1</c> set as a valid redirect URI for your application in the
        ///         Developer Portal, or this method will always return an error.
        ///     </para>
        ///     <para>Value from environment variable DISCORD_ACCESS_TOKEN</para>
        /// </summary>
        /// <param name="callback"></param>
        public void GetOAuth2Token(GetOAuth2TokenHandler callback)
        {
            GCHandle wrapped = GCHandle.Alloc(callback);

            Methods.GetOAuth2Token(methodsPtr, GCHandle.ToIntPtr(wrapped), GetOAuth2TokenCallbackImpl);
        }