小编Dun*_*Dun的帖子

如何在使用Google OAuth 2.0时阻止显示访问代码的额外视图

我按照http://googlemac.blogspot.com/2011/05/ios-and-mac-sign-in-controllers.html跟踪,允许用户使用Google登录iPhone应用.点击"允许访问"按钮后,我得到一个额外的屏幕,上面写着"请复制此代码,切换到您的应用程序并将其粘贴到那里:(文本框中的代码)."

这就是我所拥有的:

- (IBAction)googleLoginTapped:(UIButton *)sender
{
    [self loginToGoogle];
}

- (void)loginToGoogle 
{

    // For Google APIs, the scope strings are available
    // in the service constant header files.
    NSString *scope =@"https://www.googleapis.com/auth/userinfo.profile";

    // Typically, applications will hardcode the client ID and client secret
    // strings into the source code; they should not be user-editable or visible.

    // But for this sample code, they are editable.
    NSString *clientID = @"my clientID";
    NSString *clientSecret = @"my clientSecret";


    // Display the …
Run Code Online (Sandbox Code Playgroud)

ios oauth-2.0

11
推荐指数
4
解决办法
8622
查看次数

使用字节流和Dropbox API破坏docx文件

我们有一个网络应用程序,允许用户将文件上传到他们的Dropbox帐户.此Web应用程序使用Dropbox API来促进上载过程.上传后,当用户尝试查看文件类型.docx时,它会显示一条消息,"文件"somefile.docx"无法打开,因为内容存在问题".

以下是我们使用的一些代码:

首先,我们将文件转换为byte []并将其传递给API方法调用.

public static string DropboxUpload(byte[] DBbyte, string filename, string token, string tokensecret)
    {
        try
        {
            for (int i = 0; i < 4; i++)
            {
                var dropclient = new RestClient(FILEURL);
                dropclient.ClearHandlers();
                dropclient.AddHandler("*", new JsonDeserializer());

                dropclient.BaseUrl = FILEURL;
                dropclient.Authenticator = new OAuthAuthenticator(dropclient.BaseUrl, API_KEY, API_SECRET, token, tokensecret);

                var request = new RestRequest(Method.POST);
                request.Resource = VERSION + "/files/dropbox" + PATH;
                request.AddParameter("file", filename);

                request.AddFile(new FileParameter { Data = DBbyte, FileName = filename, ParameterName = "file" });

                var response = dropclient.Execute(request); …
Run Code Online (Sandbox Code Playgroud)

api docx xlsx dropbox

6
推荐指数
1
解决办法
1098
查看次数

标签 统计

api ×1

docx ×1

dropbox ×1

ios ×1

oauth-2.0 ×1

xlsx ×1